mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
|
|
namespace Chill\CustomFieldsBundle\DependencyInjection;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
use Symfony\Component\DependencyInjection\Reference;
|
|
|
|
|
|
/**
|
|
*
|
|
*
|
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
*/
|
|
class CustomFieldCompilerPass implements CompilerPassInterface
|
|
{
|
|
public function process(ContainerBuilder $container)
|
|
{
|
|
if (!$container->hasDefinition('chill.custom_field_compiler')) {
|
|
throw new \LogicException('service chill.custom_field_compiler '
|
|
. 'is not defined.');
|
|
}
|
|
|
|
$definition = $container->getDefinition(
|
|
'chill.custom_field_compiler'
|
|
);
|
|
|
|
$taggedServices = $container->findTaggedServiceIds(
|
|
'chill.custom_field'
|
|
);
|
|
|
|
foreach ($taggedServices as $id => $tagAttributes) {
|
|
foreach ($tagAttributes as $attributes) {
|
|
$definition->addMethodCall(
|
|
'addCustomField',
|
|
array(new Reference($id), $attributes["type"])
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|