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

SculpinPostsExtension::load()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 16
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 12
nc 4
nop 2
crap 12
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