SmartContentExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 72
ccs 0
cts 60
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 7 1
B prepend() 0 55 1
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