1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Netgen\Bundle\EnhancedSelectionBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\Config\Resource\FileResource; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
9
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
10
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
11
|
|
|
use Symfony\Component\Yaml\Yaml; |
12
|
|
|
|
13
|
|
|
class NetgenEnhancedSelectionExtension extends Extension implements PrependExtensionInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* {@inheritdoc} |
17
|
|
|
*/ |
18
|
|
|
public function load(array $configs, ContainerBuilder $container) |
19
|
|
|
{ |
20
|
|
|
$loader = new Loader\YamlFileLoader( |
21
|
|
|
$container, |
22
|
|
|
new FileLocator(__DIR__ . '/../Resources/config') |
23
|
|
|
); |
24
|
|
|
|
25
|
|
|
$loader->load('field_types.yml'); |
26
|
|
|
$loader->load('templating.yml'); |
27
|
|
|
|
28
|
|
|
$activatedBundles = array_keys($container->getParameter('kernel.bundles')); |
29
|
|
|
|
30
|
|
|
if (in_array('EzPublishLegacySearchEngineBundle', $activatedBundles, true)) { |
31
|
|
|
$loader->load('search/legacy.yml'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
if (in_array('EzSystemsEzPlatformSolrSearchEngineBundle', $activatedBundles, true)) { |
35
|
|
|
$loader->load('search/solr.yml'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if (in_array('EzPlatformAdminUiBundle', $activatedBundles, true)) { |
39
|
|
|
$loader->load('ezadminui/services.yml'); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Allow an extension to prepend the extension configurations. |
45
|
|
|
* |
46
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
47
|
|
|
*/ |
48
|
|
|
public function prepend(ContainerBuilder $container) |
49
|
|
|
{ |
50
|
|
|
$configFile = __DIR__ . '/../Resources/config/ezplatform.yml'; |
51
|
|
|
$config = Yaml::parse(file_get_contents($configFile)); |
52
|
|
|
$container->prependExtensionConfig('ezpublish', $config); |
53
|
|
|
$container->addResource(new FileResource($configFile)); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|