Completed
Pull Request — master (#11)
by Tomáš
03:09
created

SculpinPostsExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 24
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 18 3
1
<?php
2
3
/*
4
 * This file is a part of Sculpin.
5
 *
6
 * (c) Dragonfly Development Inc.
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 Symplify\PHP7_Sculpin\PostsBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Loader;
17
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
18
19
/**
20
 * Sculpin Posts Extension.
21
 *
22
 * @author Beau Simensen <[email protected]>
23
 */
24
class SculpinPostsExtension extends Extension
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function load(array $configs, ContainerBuilder $container)
30
    {
31
        $configuration = new Configuration();
32
        $config = $this->processConfiguration($configuration, $configs);
33
34
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
35
        $loader->load('services.yml');
36
37
        $container->setParameter('sculpin_posts.paths', $config['paths']);
38
        if (isset($config['permalink'])) {
39
            $container->setParameter('sculpin_posts.permalink', $config['permalink']);
40
        }
41
        if (isset($config['layout'])) {
42
            $container->setParameter('sculpin_posts.layout', $config['layout']);
43
        } else {
44
            $container->setParameter('sculpin_posts.layout', null);
45
        }
46
    }
47
}
48