Add compiler pass for archive builders and formatters managers

modifié:         core/lib/Thelia/Core/Bundle/TheliaBundle.php
	nouveau fichier: core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterArchiveBuilderPass.php
	nouveau fichier: core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterFormatterPass.php
This commit is contained in:
Benjamin Perche
2014-07-02 14:14:32 +02:00
parent 8ddec1a21e
commit 5f298aac75
3 changed files with 112 additions and 0 deletions

View File

@@ -17,7 +17,9 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Scope; use Symfony\Component\DependencyInjection\Scope;
use Thelia\Core\DependencyInjection\Compiler\RegisterArchiveBuilderPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterCouponPass; use Thelia\Core\DependencyInjection\Compiler\RegisterCouponPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterFormatterPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass; use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass; use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass; use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass;
@@ -57,6 +59,8 @@ class TheliaBundle extends Bundle
->addCompilerPass(new RegisterRouterPass()) ->addCompilerPass(new RegisterRouterPass())
->addCompilerPass(new RegisterCouponPass()) ->addCompilerPass(new RegisterCouponPass())
->addCompilerPass(new RegisterCouponConditionPass()) ->addCompilerPass(new RegisterCouponConditionPass())
->addCompilerPass(new RegisterArchiveBuilderPass())
->addCompilerPass(new RegisterFormatterPass())
; ;
} }
} }

View File

@@ -0,0 +1,54 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Class RegisterArchiveBuilderPass
* @package Thelia\Core\DependencyInjection\Compiler
* @author Benjamin Perche <bperche@openstudio.fr>
*/
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)
)
);
}
}
}

View File

@@ -0,0 +1,54 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Class RegisterFormatterPass
* @package Thelia\Core\DependencyInjection\Compiler
* @author Benjamin Perche <bperche@openstudio.fr>
*/
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)
)
);
}
}
}