StfalconApiExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/*
3
 * This file is part of the StfalconApiBundle.
4
 *
5
 * (c) Stfalcon LLC <stfalcon.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace StfalconStudio\ApiBundle\DependencyInjection;
14
15
use StfalconStudio\ApiBundle\Service\Exception\ResponseProcessor\CustomAppExceptionResponseProcessorInterface;
16
use Symfony\Component\Config\FileLocator;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20
21
/**
22
 * This is the class, that loads and manages StfalconApiBundle configuration.
23
 */
24
class StfalconApiExtension extends Extension
25
{
26
    /**
27
     * @param mixed[]          $configs
28
     * @param ContainerBuilder $container
29
     */
30
    public function load(array $configs, ContainerBuilder $container): void
31
    {
32
        $configuration = new Configuration();
33
        $config = $this->processConfiguration($configuration, $configs);
34
35
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
36
        $loader->load('services.yaml');
37
38
        $container->setParameter('stfalcon_api.json_schema_dir', $config['json_schema_dir']);
39
        $container->registerForAutoconfiguration(CustomAppExceptionResponseProcessorInterface::class)->addTag('stfalcon_api.exception_response_processor');
40
    }
41
}
42