SmartContentExtension::prepend()   B
last analyzed

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
        $loader->load('repository.xml');
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function prepend(ContainerBuilder $container)
31
    {
32
        $container->prependExtensionConfig('sonata_admin', [
33
            'extensions' => [
34
                'smart_content.admin.extension.nameable' => [
35
                    'uses' => ['Smart\ContentBundle\Entity\Traits\NameableTrait'],
36
                    'priority' => 100
37
                ],
38
                'smart_content.admin.extension.content' => [
39
                    'uses' => ['Smart\ContentBundle\Entity\Traits\ContentTrait'],
40
                    'priority' => 80
41
                ],
42
                'smart_content.admin.extension.image' => [
43
                    'uses' => ['Smart\ContentBundle\Entity\Traits\ImageTrait'],
44
                    'priority' => 60
45
                ],
46
                'smart_content.admin.extension.seo' => [
47
                    'uses' => ['Smart\ContentBundle\Entity\Traits\SeoTrait'],
48
                    'priority' => 40
49
                ],
50
            ]
51
        ]);
52
        $container->prependExtensionConfig('twig', [
53
            'form_theme' => [
54
                '@SonataCore/Form/datepicker.html.twig'
55
            ]
56
        ]);
57
58
        $container->prependExtensionConfig('vich_uploader', [
59
            'db_driver' => 'orm',
60
            'mappings' => [
61
                'smart_content_image' => [
62
                    'namer' => 'smart_content.upload.content_image_namer',
63
                    'directory_namer' => 'smart_content.upload.content_image_directory_namer',
64
                    'uri_prefix' => '/upload/content',
65
                    'upload_destination' => '%kernel.root_dir%/../public/upload/content',
66
                ]
67
            ]
68
        ]);
69
70
        $container->prependExtensionConfig('liip_imagine', [
71
            'filter_sets' => [
72
                'smart_content_list_thumb' => [
73
                    'filters' => [
74
                        'thumbnail' => ['size' => [32, 32], 'mode' => 'outbound']
75
                    ]
76
                ],
77
                'smart_content_show_thumb' => [
78
                    'filters' => [
79
                        'thumbnail' => ['size' => [300, 300], 'mode' => 'inset']
80
                    ]
81
                ]
82
            ]
83
        ]);
84
    }
85
}
86