ServiceCompilerPass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 17 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\SeoBundle\DependencyInjection\Compiler;
15
16
use Sonata\SeoBundle\Seo\SeoPageInterface;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
/**
21
 * @author Christian Gripp <[email protected]>
22
 */
23
final class ServiceCompilerPass implements CompilerPassInterface
24
{
25
    public function process(ContainerBuilder $container): void
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
        $container->setAlias(SeoPageInterface::class, $config['default']);
41
    }
42
}
43