|
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\AnalyticsBundle\EventListener\MetricsListener; |
|
18
|
|
|
use SWP\Bundle\CoreBundle\Detection\DeviceDetection; |
|
19
|
|
|
use SWP\Bundle\CoreBundle\Enhancer\RouteEnhancer; |
|
20
|
|
|
use SWP\Bundle\CoreBundle\Resolver\TemplateNameResolver; |
|
21
|
|
|
use SWP\Bundle\CoreBundle\Theme\TenantAwareThemeContext; |
|
22
|
|
|
use SWP\Bundle\MultiTenancyBundle\Context\TenantContext; |
|
23
|
|
|
use SWP\Bundle\MultiTenancyBundle\EventListener\TenantableListener; |
|
24
|
|
|
use SWP\Bundle\MultiTenancyBundle\Query\Filter\TenantableFilter; |
|
25
|
|
|
use SWP\Bundle\MultiTenancyBundle\Routing\TenantAwareRouter; |
|
26
|
|
|
use SWP\Bundle\StorageBundle\DependencyInjection\Extension\Extension; |
|
27
|
|
|
use SWP\Bundle\StorageBundle\Drivers; |
|
28
|
|
|
use SWP\Component\MultiTenancy\Model\TenantAwareTrait; |
|
29
|
|
|
use SWP\Component\MultiTenancy\Resolver\TenantResolver; |
|
30
|
|
|
use SWP\Component\TemplatesSystem\Gimme\Context\Context; |
|
31
|
|
|
use Symfony\Component\Config\FileLocator; |
|
32
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
33
|
2 |
|
use Symfony\Component\DependencyInjection\Loader; |
|
34
|
|
|
use Symfony\Component\HttpKernel\EventListener\RouterListener; |
|
35
|
2 |
|
|
|
36
|
2 |
|
/** |
|
37
|
2 |
|
* This is the class that loads and manages your bundle configuration. |
|
38
|
2 |
|
* |
|
39
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
|
40
|
2 |
|
*/ |
|
41
|
2 |
|
class SWPCoreExtension extends Extension |
|
42
|
|
|
{ |
|
43
|
2 |
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
2 |
|
*/ |
|
46
|
1 |
|
public function load(array $configs, ContainerBuilder $container) |
|
47
|
|
|
{ |
|
48
|
2 |
|
$config = $this->processConfiguration(new Configuration(), $configs); |
|
49
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
50
|
|
|
$loader->load('services.yml'); |
|
51
|
|
|
$this->loadDeviceListener($config, $loader); |
|
52
|
|
|
|
|
53
|
|
|
$this->registerStorage(Drivers::DRIVER_DOCTRINE_ORM, $config['persistence']['orm']['classes'], $container); |
|
54
|
|
|
|
|
55
|
|
|
$this->addClassesToCompile(array( |
|
56
|
|
|
TenantAwareThemeContext::class, |
|
57
|
|
|
TenantAwareRouter::class, |
|
58
|
|
|
TenantAwareTrait::class, |
|
59
|
|
|
TenantResolver::class, |
|
60
|
|
|
TenantContext::class, |
|
61
|
|
|
RouteEnhancer::class, |
|
62
|
|
|
RouterListener::class, |
|
63
|
|
|
TemplateNameResolver::class, |
|
64
|
|
|
TenantableListener::class, |
|
65
|
|
|
TenantableFilter::class, |
|
66
|
|
|
MetricsListener::class, |
|
67
|
|
|
Context::class, |
|
68
|
|
|
)); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
private function loadDeviceListener(array $config, Loader\YamlFileLoader $loader) |
|
72
|
|
|
{ |
|
73
|
|
|
if ($config['device_listener']['enabled']) { |
|
74
|
|
|
$loader->load('device_listener.yml'); |
|
75
|
|
|
$this->addClassesToCompile(array( |
|
76
|
|
|
DeviceDetection::class, |
|
77
|
|
|
)); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|