forked from ckapp/IbrowsNewsletterBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RendererCompilerPass.php
45 lines (36 loc) · 1.37 KB
/
RendererCompilerPass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Ibrows\Bundle\NewsletterBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;
class RendererCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
// add all tagged renderers
if (!$container->hasDefinition('ibrows_newsletter.renderer_manager')) {
return;
}
$definition = $container->getDefinition(
'ibrows_newsletter.renderer_manager'
);
$taggedServices = $container->findTaggedServiceIds(
'ibrows_newsletter.renderer'
);
foreach ($taggedServices as $id => $attributes) {
$definition->addMethodCall(
'addRenderer',
array($id, new Reference($id))
);
}
// set correct gendertitle strategy
if (!$container->hasDefinition('ibrows_newsletter.rendererbridge')) {
return;
}
$definition = $container->getDefinition(
'ibrows_newsletter.rendererbridge'
);
$genderTitleStrategyServiceId = $container->getParameter('ibrows_newsletter.serviceid.gendertitlestrategy');
$definition->addArgument(new Reference($genderTitleStrategyServiceId));
}
}