Skip to content

Commit

Permalink
Merge pull request #11 from xima-media/typoscript-include
Browse files Browse the repository at this point in the history
Only render js if typoscript is included
  • Loading branch information
jackd248 authored Dec 12, 2024
2 parents b8b6878 + 4e749f8 commit 17a4304
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit 17a4304

Please sign in to comment.