Completed
Push — 2.x ( 5969b2...2b7d1f )
by Grégoire
15:29
created

ServiceCompilerPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\SeoBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * @author Christian Gripp <[email protected]>
19
 */
20
final class ServiceCompilerPass implements CompilerPassInterface
21
{
22
    public function process(ContainerBuilder $container)
23
    {
24
        $config = $container->getParameter('sonata.seo.config');
25
26
        $definition = $container->findDefinition($config['default']);
27
28
        $definition->addMethodCall('setTitle', [$config['title']]);
29
        $definition->addMethodCall('setMetas', [$config['metas']]);
30
        $definition->addMethodCall('setHtmlAttributes', [$config['head']]);
31
        $definition->addMethodCall('setSeparator', [$config['separator']]);
32
33
        if ($alias = $container->setAlias('sonata.seo.page', $config['default'])) {
34
            $alias->setPublic(true);
35
        }
36
    }
37
}
38