Completed
Pull Request — 2.x (#287)
by Christian
12:28
created

ServiceCompilerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 2
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
    /**
23
     * {@inheritdoc}
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        $config = $container->getParameter('sonata.seo.config');
28
29
        $definition = $container->findDefinition($config['default']);
30
31
        $definition->addMethodCall('setTitle', [$config['title']]);
32
        $definition->addMethodCall('setMetas', [$config['metas']]);
33
        $definition->addMethodCall('setHtmlAttributes', [$config['head']]);
34
        $definition->addMethodCall('setSeparator', [$config['separator']]);
35
36
        if ($alias = $container->setAlias('sonata.seo.page', $config['default'])) {
37
            $alias->setPublic(true);
38
        }
39
    }
40
}
41