1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Superdesk Web Publisher Core Bundle. |
5
|
|
|
* |
6
|
|
|
* Copyright 2015 Sourcefabric z.u. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2015 Sourcefabric z.ú |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace SWP\Bundle\CoreBundle\DependencyInjection; |
16
|
|
|
|
17
|
|
|
use SWP\Bundle\CoreBundle\Model\ContentList; |
18
|
|
|
use SWP\Bundle\StorageBundle\DependencyInjection\Extension\Extension; |
19
|
|
|
use SWP\Bundle\StorageBundle\Drivers; |
20
|
|
|
use Symfony\Component\Config\FileLocator; |
21
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
22
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
23
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* This is the class that loads and manages your bundle configuration. |
27
|
|
|
* |
28
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
29
|
|
|
*/ |
30
|
|
|
class SWPCoreExtension extends Extension implements PrependExtensionInterface |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
2 |
|
public function load(array $configs, ContainerBuilder $container) |
36
|
|
|
{ |
37
|
2 |
|
$config = $this->processConfiguration(new Configuration(), $configs); |
38
|
2 |
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
39
|
2 |
|
$loader->load('services.yml'); |
40
|
2 |
|
$this->loadDeviceListener($config, $loader); |
41
|
|
|
|
42
|
2 |
|
$this->registerStorage(Drivers::DRIVER_DOCTRINE_ORM, $config['persistence']['orm']['classes'], $container); |
43
|
2 |
|
} |
44
|
|
|
|
45
|
2 |
|
private function loadDeviceListener(array $config, Loader\YamlFileLoader $loader) |
46
|
|
|
{ |
47
|
2 |
|
if ($config['device_listener']['enabled']) { |
48
|
1 |
|
$loader->load('device_listener.yml'); |
49
|
|
|
} |
50
|
2 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
1 |
|
public function prepend(ContainerBuilder $container) |
56
|
|
|
{ |
57
|
1 |
|
$config = $this->processConfiguration(new Configuration(), $container->getExtensionConfig($this->getAlias())); |
58
|
|
|
|
59
|
1 |
|
if (!$container->hasExtension('swp_content_list')) { |
60
|
|
|
return; |
61
|
|
|
} |
62
|
|
|
|
63
|
1 |
|
$container->prependExtensionConfig('swp_content_list', [ |
64
|
|
|
'persistence' => [ |
65
|
|
|
'orm' => [ |
66
|
1 |
|
'enabled' => $config['persistence']['orm']['enabled'], |
67
|
|
|
'classes' => [ |
68
|
|
|
'content_list' => [ |
69
|
|
|
'model' => ContentList::class, |
70
|
|
|
], |
71
|
|
|
], |
72
|
|
|
], |
73
|
1 |
|
], |
74
|
|
|
]); |
75
|
1 |
|
} |
76
|
|
|
} |
77
|
|
|
|