From 762659e6275ae6190fe450e433c39aa9da4e1bfd Mon Sep 17 00:00:00 2001 From: DerBasti Date: Fri, 5 Jan 2018 08:10:25 +0100 Subject: [PATCH] Implementing SignalSlotDispatcher after a file is parsed (#52) * [TASK] implementing SignalSlotDispatcher after getting fileContent in AbstractParser Class * [TASK] adding constant for SignalSlotDispatcher --- Classes/Parser/AbstractParser.php | 15 +++++++++++++++ ext_emconf.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Classes/Parser/AbstractParser.php b/Classes/Parser/AbstractParser.php index 7a9a804..b28c2a3 100644 --- a/Classes/Parser/AbstractParser.php +++ b/Classes/Parser/AbstractParser.php @@ -11,6 +11,8 @@ */ abstract class AbstractParser implements ParserInterface { + const SIGNAL_DYNCSS_AFTER_FILE_PARSED = 'afterFileParsed'; + /** * @var array */ @@ -36,9 +38,19 @@ abstract class AbstractParser implements ParserInterface */ protected $config = []; + /** + * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher + */ + protected $signalSlotDispatcher; + + public function __construct() { $this->initEmConfiguration(); + + // ObjectManager => get SignalSlotDispatcher + $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); + $this->signalSlotDispatcher = $objectManager->get(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); } /** @@ -290,6 +302,9 @@ public function compileFile($inputFilename, $outputFilename = null) $fileContent = $this->_postCompile($this->_compileFile($inputFilename, $preparedFilename, $outputFilename, $cacheFilename)); + // dispatch signal + $fileContent = $this->signalSlotDispatcher->dispatch(__CLASS__, self::SIGNAL_DYNCSS_AFTER_FILE_PARSED, [$fileContent]); + if ($fileContent !== false) { file_put_contents($outputFilename, $fileContent); // important for some cache clearing scenarios diff --git a/ext_emconf.php b/ext_emconf.php index b6b3038..c8183d6 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -15,7 +15,7 @@ 'description' => 'Compile your CSS dynamically with DynCss Adapters.', 'category' => 'fe', 'shy' => 0, - 'version' => '0.8.2', + 'version' => '0.8.3', 'dependencies' => '', 'conflicts' => '', 'priority' => '',