Completed
Pull Request — master (#10)
by Tomáš
04:50 queued 01:55
created

SculpinPostsExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 30
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 24 4
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\Bundle\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
        if (null !== $config['publish_drafts']) {
48
            $container->setParameter('sculpin_posts.publish_drafts', $config['publish_drafts']);
49
        } else {
50
            $container->setParameter('sculpin_posts.publish_drafts', 'prod' !== $container->getParameter('kernel.environment'));
51
        }
52
    }
53
}
54