Completed
Push — master ( 57b021...d38ccd )
by Nicolas
29:22 queued 27:52
created

SmartContentExtension::prepend()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 55

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 55
ccs 0
cts 53
cp 0
rs 8.9818
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Smart\ContentBundle\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\XmlFileLoader;
9
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
10
11
/**
12
 * Nicolas Bastien <[email protected]>
13
 */
14
class SmartContentExtension extends Extension implements PrependExtensionInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function load(array $configs, ContainerBuilder $container)
20
    {
21
        $loader = new XmlFileLoader($container, new FileLocator(sprintf('%s/../Resources/config', __DIR__)));
22
        $loader->load('admin.xml');
23
        $loader->load('service.xml');
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function prepend(ContainerBuilder $container)
30
    {
31
        $container->prependExtensionConfig('sonata_admin', [
32
            'extensions' => [
33
                'smart_content.admin.extension.nameable' => [
34
                    'uses' => ['Smart\ContentBundle\Entity\Traits\NameableTrait'],
35
                    'priority' => 100
36
                ],
37
                'smart_content.admin.extension.content' => [
38
                    'uses' => ['Smart\ContentBundle\Entity\Traits\ContentTrait'],
39
                    'priority' => 80
40
                ],
41
                'smart_content.admin.extension.image' => [
42
                    'uses' => ['Smart\ContentBundle\Entity\Traits\ImageTrait'],
43
                    'priority' => 60
44
                ],
45
                'smart_content.admin.extension.seo' => [
46
                    'uses' => ['Smart\ContentBundle\Entity\Traits\SeoTrait'],
47
                    'priority' => 40
48
                ],
49
            ]
50
        ]);
51
        $container->prependExtensionConfig('twig', [
52
            'form_theme' => [
53
                '@SonataCore/Form/datepicker.html.twig'
54
            ]
55
        ]);
56
57
        $container->prependExtensionConfig('vich_uploader', [
58
            'db_driver' => 'orm',
59
            'mappings' => [
60
                'smart_content_image' => [
61
                    'namer' => 'smart_content.upload.content_image_namer',
62
                    'directory_namer' => 'smart_content.upload.content_image_directory_namer',
63
                    'uri_prefix' => '/upload/content',
64
                    'upload_destination' => '%kernel.root_dir%/../public/upload/content',
65
                ]
66
            ]
67
        ]);
68
69
        $container->prependExtensionConfig('liip_imagine', [
70
            'filter_sets' => [
71
                'smart_content_list_thumb' => [
72
                    'filters' => [
73
                        'thumbnail' => ['size' => [32, 32], 'mode' => 'outbound']
74
                    ]
75
                ],
76
                'smart_content_show_thumb' => [
77
                    'filters' => [
78
                        'thumbnail' => ['size' => [300, 300], 'mode' => 'inset']
79
                    ]
80
                ]
81
            ]
82
        ]);
83
    }
84
}
85