Skip to content

Commit 80144d6

Browse files
committed
add event AfterVariableDefinition
1 parent 8f9d765 commit 80144d6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WapplerSystems\WsScss\Event;
6+
7+
final class AfterVariableDefinitionEvent
8+
{
9+
public function __construct(private array $variables)
10+
{
11+
}
12+
13+
public function getVariables(): array
14+
{
15+
return $this->variables;
16+
}
17+
18+
public function setVariables(array $variables): void
19+
{
20+
$this->variables = $variables;
21+
}
22+
}

Classes/Hooks/RenderPreProcessorHook.php

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* This copyright notice MUST APPEAR in all copies of the script!
2323
***************************************************************/
2424

25+
use Psr\EventDispatcher\EventDispatcherInterface;
2526
use ScssPhp\ScssPhp\Exception\SassException;
2627
use ScssPhp\ScssPhp\OutputStyle;
2728
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
@@ -32,6 +33,7 @@
3233
use TYPO3\CMS\Core\Utility\PathUtility;
3334
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
3435
use WapplerSystems\WsScss\Compiler;
36+
use WapplerSystems\WsScss\Event\AfterVariableDefinitionEvent;
3537

3638
/**
3739
* Hook to preprocess scss files
@@ -93,6 +95,10 @@ public function renderPreProcessorProc(array &$params, PageRenderer $pageRendere
9395
$this->variables = $parsedTypoScriptVariables;
9496
}
9597

98+
$eventDispatcher = GeneralUtility::makeInstance(EventDispatcherInterface::class);
99+
$event = $eventDispatcher->dispatch(new AfterVariableDefinitionEvent($this->variables));
100+
$this->variables = $event->getVariables();
101+
96102
// we need to rebuild the CSS array to keep order of CSS files
97103
$cssFiles = [];
98104
foreach ($params['cssFiles'] as $file => $conf) {

0 commit comments

Comments
 (0)