LakionCmsExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 12 1
A prepend() 0 6 1
1
<?php
2
3
namespace Lakion\CmsPlugin\DependencyInjection;
4
5
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
6
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
10
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
11
use Symfony\Component\DependencyInjection\Parameter;
12
13
final class LakionCmsExtension extends AbstractResourceExtension implements PrependExtensionInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function load(array $config, ContainerBuilder $container)
19
    {
20
        $config = $this->processConfiguration($this->getConfiguration([], $container), $config);
0 ignored issues
show
Documentation introduced by
$this->getConfiguration(array(), $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...
21
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
22
23
        $this->registerResources('lakion_cms', SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM, $config['resources'], $container);
24
25
        $loader->load('services.xml');
26
27
        $staticContentRepository = $container->getDefinition('lakion_cms.repository.static_content');
28
        $staticContentRepository->addArgument(new Parameter('cmf_content.persistence.phpcr.content_basepath'));
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function prepend(ContainerBuilder $container)
35
    {
36
        $config = $this->processConfiguration($this->getConfiguration([], $container), $container->getExtensionConfig($this->getAlias()));
0 ignored issues
show
Documentation introduced by
$this->getConfiguration(array(), $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...
37
38
        $this->registerResources('lakion_cms', SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM, $config['resources'], $container);
39
    }
40
}
41