Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only render js if typoscript is included #11

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Classes/Middleware/ToolRendererMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@

class ToolRendererMiddleware implements MiddlewareInterface
{
public function __construct(protected readonly ResourceRenderer $resourceRenderer)
public function __construct(protected ResourceRenderer $resourceRenderer)
{
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
$typoScriptConfig = $GLOBALS['TSFE']->config['config'];

if (
$GLOBALS['BE_USER']
array_key_exists('tx_ximatypo3frontendedit_enable', $typoScriptConfig)
&& $typoScriptConfig['tx_ximatypo3frontendedit_enable']
&& $GLOBALS['BE_USER']
&& (!array_key_exists('tx_ximatypo3frontendedit_disable', $GLOBALS['BE_USER']->user) || !$GLOBALS['BE_USER']->user['tx_ximatypo3frontendedit_disable'])
) {
$body = $response->getBody();
Expand Down
3 changes: 3 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ tx_ximatypo3frontendedit_editinformationen {
no_cache = 1
}
}

# This config is set to control the ToolRendererMiddleware depending on whether the typoscript is included on the current site or not.
config.tx_ximatypo3frontendedit_enable = 1
Loading