|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Superdesk Web Publisher MultiTenancy 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
|
|
|
namespace SWP\MultiTenancyBundle\DependencyInjection; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17
|
|
|
use Symfony\Component\Config\FileLocator; |
|
18
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* This is the class that loads and manages your bundle configuration. |
|
23
|
|
|
* |
|
24
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
|
25
|
|
|
*/ |
|
26
|
|
|
class SWPMultiTenancyExtension extends Extension |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
32
|
|
|
{ |
|
33
|
|
|
$configuration = new Configuration(); |
|
34
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
35
|
|
|
|
|
36
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
37
|
|
|
$loader->load('services.yml'); |
|
38
|
|
|
|
|
39
|
|
|
if ($config['persistence']['phpcr']['enabled']) { |
|
40
|
|
|
$this->loadPhpcr($config['persistence']['phpcr'], $loader, $container); |
|
41
|
|
|
$container->setParameter($this->getAlias().'.backend_type_phpcr', true); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function loadPhpcr($config, YamlFileLoader $loader, ContainerBuilder $container) |
|
46
|
|
|
{ |
|
47
|
|
|
$keys = array( |
|
48
|
|
|
'basepath' => 'basepath', |
|
49
|
|
|
'route_basepaths' => 'route_basepaths', |
|
50
|
|
|
'content_basepath' => 'content_basepath', |
|
51
|
|
|
'site_document_class' => 'site_document.class', |
|
52
|
|
|
'tenant_aware_router_class' => 'router.class', |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
|
|
foreach ($keys as $sourceKey => $targetKey) { |
|
56
|
|
|
$container->setParameter( |
|
57
|
|
|
$this->getAlias().'.persistence.phpcr.'.$targetKey, |
|
58
|
|
|
$config[$sourceKey] |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
array_push($config['route_basepaths'], $config['content_basepath']); |
|
63
|
|
|
|
|
64
|
|
|
$container->setParameter( |
|
65
|
|
|
$this->getAlias().'.persistence.phpcr.base_paths', |
|
66
|
|
|
$config['route_basepaths'] |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
$loader->load('phpcr.yml'); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|