Completed
Pull Request — master (#8)
by Nicolas
28:01
created

SmartContentExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 71
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 71
ccs 0
cts 59
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 6 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
    }
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