From 5f298aac75ec2a02bc32051f093cb79f8e8bd496 Mon Sep 17 00:00:00 2001 From: Benjamin Perche Date: Wed, 2 Jul 2014 14:14:32 +0200 Subject: [PATCH] =?UTF-8?q?Add=20compiler=20pass=20for=20archive=20builder?= =?UTF-8?q?s=20and=20formatters=20managers=20=09modifi=C3=A9:=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20core/lib/Thelia/Core/Bundle/TheliaBundle.php=20?= =?UTF-8?q?=09nouveau=20fichier:=20core/lib/Thelia/Core/DependencyInjectio?= =?UTF-8?q?n/Compiler/RegisterArchiveBuilderPass.php=20=09nouveau=20fichie?= =?UTF-8?q?r:=20core/lib/Thelia/Core/DependencyInjection/Compiler/Register?= =?UTF-8?q?FormatterPass.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/lib/Thelia/Core/Bundle/TheliaBundle.php | 4 ++ .../Compiler/RegisterArchiveBuilderPass.php | 54 +++++++++++++++++++ .../Compiler/RegisterFormatterPass.php | 54 +++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterArchiveBuilderPass.php create mode 100644 core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterFormatterPass.php diff --git a/core/lib/Thelia/Core/Bundle/TheliaBundle.php b/core/lib/Thelia/Core/Bundle/TheliaBundle.php index bb476c402..69065eccc 100644 --- a/core/lib/Thelia/Core/Bundle/TheliaBundle.php +++ b/core/lib/Thelia/Core/Bundle/TheliaBundle.php @@ -17,7 +17,9 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Scope; +use Thelia\Core\DependencyInjection\Compiler\RegisterArchiveBuilderPass; use Thelia\Core\DependencyInjection\Compiler\RegisterCouponPass; +use Thelia\Core\DependencyInjection\Compiler\RegisterFormatterPass; use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass; use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass; use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass; @@ -57,6 +59,8 @@ class TheliaBundle extends Bundle ->addCompilerPass(new RegisterRouterPass()) ->addCompilerPass(new RegisterCouponPass()) ->addCompilerPass(new RegisterCouponConditionPass()) + ->addCompilerPass(new RegisterArchiveBuilderPass()) + ->addCompilerPass(new RegisterFormatterPass()) ; } } diff --git a/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterArchiveBuilderPass.php b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterArchiveBuilderPass.php new file mode 100644 index 000000000..590e307d7 --- /dev/null +++ b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterArchiveBuilderPass.php @@ -0,0 +1,54 @@ + + */ +class RegisterArchiveBuilderPass implements CompilerPassInterface +{ + const MANAGER_DEFINITION = "thelia.manager.archive_builder_manager"; + + const SERVICE_TAG = "thelia.manager.archive_builder"; + + /** + * You can modify the container here before it is dumped to PHP code. + * + * @param ContainerBuilder $container Container + * + * @api + */ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition(static::MANAGER_DEFINITION)) { + return; + } + + $manager = $container->getDefinition(static::MANAGER_DEFINITION); + $services = $container->findTaggedServiceIds(static::SERVICE_TAG); + + foreach ($services as $id => $condition) { + $manager->addMethodCall( + 'add', + array( + new Reference($id) + ) + ); + } + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterFormatterPass.php b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterFormatterPass.php new file mode 100644 index 000000000..c10fb8dde --- /dev/null +++ b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterFormatterPass.php @@ -0,0 +1,54 @@ + + */ +class RegisterFormatterPass implements CompilerPassInterface +{ + const MANAGER_DEFINITION = "thelia.manager.formatter_manager"; + + const SERVICE_TAG = "thelia.manager.formatter"; + + /** + * You can modify the container here before it is dumped to PHP code. + * + * @param ContainerBuilder $container Container + * + * @api + */ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition(static::MANAGER_DEFINITION)) { + return; + } + + $manager = $container->getDefinition(static::MANAGER_DEFINITION); + $services = $container->findTaggedServiceIds(static::SERVICE_TAG); + + foreach ($services as $id => $condition) { + $manager->addMethodCall( + 'add', + array( + new Reference($id) + ) + ); + } + } +} \ No newline at end of file