From 95c0695251f915c09739c1c3d23864f36466d8ad Mon Sep 17 00:00:00 2001 From: Loktionov Alexey Date: Wed, 25 Nov 2020 20:17:40 +0300 Subject: [PATCH] Enable event dispatcher (#6) * enable symfony event dispatcher component * finetune Co-authored-by: Konstantin Vanderer --- .gitignore | 1 + CHANGELOG.md | 3 +++ etc/services/event_dispatcher.yml | 4 ++++ lib/common.version.inc | 2 +- src/DependencyInjection/CoreExtension.php | 3 +++ src/Lib/Engine/AbstractEngine.php | 5 ++++- 6 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 etc/services/event_dispatcher.yml diff --git a/.gitignore b/.gitignore index 18fa551d..31fc5ca8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /auth.json composer.lock *.iml +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index cfda449e..62d18445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change log +## [2.4.5] 2020-11-19 +- Включен symfony EventDispatcher Component + ## [2.4.4] 2020-11-19 - Исправлен баг с фильтрацией unicode имен файлов diff --git a/etc/services/event_dispatcher.yml b/etc/services/event_dispatcher.yml new file mode 100644 index 00000000..3ef86879 --- /dev/null +++ b/etc/services/event_dispatcher.yml @@ -0,0 +1,4 @@ +services: + event_dispatcher: + class: Symfony\Component\EventDispatcher\EventDispatcher + public: true diff --git a/lib/common.version.inc b/lib/common.version.inc index 5957a60a..3cdcc512 100644 --- a/lib/common.version.inc +++ b/lib/common.version.inc @@ -1,3 +1,3 @@ setParameter('core.cache_dir', CACHE_PATH); $container->setParameter('core.runtime_dir', RUNTIME_PATH); + // register event dispatcher configuration + $loader->load('event_dispatcher.yml'); + $this->registerLoggerConfiguration($config['application'], $container, $loader); } diff --git a/src/Lib/Engine/AbstractEngine.php b/src/Lib/Engine/AbstractEngine.php index 72b6bb9b..bdc587a8 100644 --- a/src/Lib/Engine/AbstractEngine.php +++ b/src/Lib/Engine/AbstractEngine.php @@ -11,6 +11,7 @@ use PP\Lib\Html\Layout\LayoutInterface; use PP\ApplicationFactory; use Symfony\Component\Config\ConfigCache; +use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; abstract class AbstractEngine implements EngineInterface { @@ -109,7 +110,9 @@ protected function initContainer($klass) /** @var ContainerBuilder $container */ $container = new $klass(); $container->registerExtension(new CoreExtension()); - $container->addCompilerPass(new AddLoggingHandlersPass()); + $container + ->addCompilerPass(new AddLoggingHandlersPass()) + ->addCompilerPass(new RegisterListenersPass()); $loader = new YamlFileLoader($container, new FileLocator($path));