Completed
Push — symfony-fqcn-sylius-4 ( 896d93...f41f61 )
by Kamil
18:34
created

SyliusAttributeExtension::resolveSubjectsConfigutaion()   B

Complexity

Conditions 6
Paths 7

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.5125
c 0
b 0
f 0
cc 6
eloc 13
nc 7
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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 Sylius\Bundle\AttributeBundle\DependencyInjection;
13
14
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18
19
/**
20
 * @author Paweł Jędrzejewski <[email protected]>
21
 */
22
final class SyliusAttributeExtension extends AbstractResourceExtension
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function load(array $config, ContainerBuilder $container)
28
    {
29
        $config = $this->processConfiguration($this->getConfiguration($config, $container), $config);
0 ignored issues
show
Documentation introduced by
$this->getConfiguration($config, $container) is of type object|null, but the function expects a object<Symfony\Component...ConfigurationInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
30
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
31
32
        $loader->load('services.xml');
33
34
        $this->registerResources('sylius', $config['driver'], $this->resolveResources($config['resources'], $container), $container);
35
    }
36
37
    /**
38
     * @param array $resources
39
     * @param ContainerBuilder $container
40
     *
41
     * @return array
42
     */
43
    private function resolveResources(array $resources, ContainerBuilder $container)
44
    {
45
        $container->setParameter('sylius.attribute.subjects', $resources);
46
47
        $resolvedResources = [];
48
        foreach ($resources as $subjectName => $subjectConfig) {
49
            foreach ($subjectConfig as $resourceName => $resourceConfig) {
50
                if (is_array($resourceConfig)) {
51
                    $resolvedResources[$subjectName.'_'.$resourceName] = $resourceConfig;
52
                }
53
            }
54
        }
55
56
        return $resolvedResources;
57
    }
58
}
59