Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
created

DependencyInjection/KunstmaanFormExtension.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\FormBundle\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
8
use Symfony\Component\DependencyInjection\Loader;
9
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
10
11
/**
12
 * This is the class that loads and manages your bundle configuration
13
 *
14
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
15
 */
16
class KunstmaanFormExtension extends Extension implements PrependExtensionInterface
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21 View Code Duplication
    public function load(array $configs, ContainerBuilder $container)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        $configuration = new Configuration();
24
        $config = $this->processConfiguration($configuration, $configs);
25
26
        $container->setParameter('kunstmaan_form.deletable_formsubmissions', $config['deletable_formsubmissions']);
27
28
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
29
        $loader->load('services.yml');
30
    }
31
32
    public function prepend(ContainerBuilder $container)
33
    {
34
        if (!$container->hasParameter('form_submission_rootdir')) {
35
            $container->setParameter('form_submission_rootdir',
36
                sprintf('%s/../web/uploads/formsubmissions', $container->getParameter('kernel.root_dir')));
37
        }
38
39
        if (!$container->hasParameter('form_submission_webdir')) {
40
            $container->setParameter('form_submission_webdir', '/uploads/formsubmissions/');
41
        }
42
43
        $twigConfig['globals']['form_submission_webdir'] = $container->getParameter('form_submission_webdir');
44
        $container->prependExtensionConfig('twig', $twigConfig);
45
        $configs = $container->getExtensionConfig($this->getAlias());
46
        $this->processConfiguration(new Configuration(), $configs);
47
    }
48
}
49