Completed
Push — master ( dc6a94...5d02ae )
by Rafał
09:03
created

SWPContentExtension::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
ccs 7
cts 7
cp 1
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Content Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\ContentBundle\DependencyInjection;
16
17
use SWP\Bundle\StorageBundle\Drivers;
18
use SWP\Bundle\StorageBundle\DependencyInjection\Extension\Extension;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\Config\FileLocator;
21
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
22
use Symfony\Component\DependencyInjection\Loader;
23
24
/**
25
 * This is the class that loads and manages your bundle configuration.
26
 *
27
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
28
 */
29
class SWPContentExtension extends Extension implements PrependExtensionInterface
30
{
31
    /**
32
     * {@inheritdoc}
33 1
     */
34
    public function load(array $configs, ContainerBuilder $container)
35 1
    {
36 1
        $config = $this->processConfiguration(new Configuration(), $configs);
37 1
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
38
        $loader->load('services.yml');
39 1
40 1
        if ($config['persistence']['orm']['enabled']) {
41 1
            $this->registerStorage(Drivers::DRIVER_DOCTRINE_ORM, $config['persistence']['orm']['classes'], $container);
42
            $loader->load('providers.orm.yml');
43 1
        }
44
    }
45
46
    public function prepend(ContainerBuilder $container): void
47
    {
48
        $config = [
49
            [
50
                'adapters' => [
51
                    'fallback_adapter' => [
52
                        'fallback' => [
53
                            'mainAdapter' => '%env(resolve:FS_MAIN_ADAPTER)%',
54
                            'fallback' => 'local_adapter',
55
                            'forceCopyOnMain' => false,
56
                        ],
57
                    ],
58
                ],
59
            ],
60
        ];
61
62
        $config = $container->resolveEnvPlaceholders(
63
            $config,
64
            true
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string|object<Symfony\Co...ncyInjection\true>|null.

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...
65
        );
66
67
        $container->prependExtensionConfig('oneup_flysystem', $config[0]);
68
    }
69
}
70