|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Netgen\Bundle\InformationCollectionBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor; |
|
6
|
|
|
use Symfony\Component\Config\FileLocator; |
|
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\Config\Resource\FileResource; |
|
12
|
|
|
use Symfony\Component\Yaml\Yaml; |
|
13
|
|
|
use function array_merge; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* This is the class that loads and manages your bundle configuration. |
|
17
|
|
|
* |
|
18
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
|
19
|
|
|
*/ |
|
20
|
|
|
class NetgenInformationCollectionExtension extends Extension implements PrependExtensionInterface |
|
21
|
1 |
|
{ |
|
22
|
|
|
/** |
|
23
|
1 |
|
* {@inheritdoc} |
|
24
|
1 |
|
*/ |
|
25
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
26
|
1 |
|
{ |
|
27
|
1 |
|
$configuration = new Configuration(); |
|
28
|
1 |
|
$config = $this->processConfiguration($configuration, $configs); |
|
29
|
|
|
|
|
30
|
1 |
|
$bundleResourceLoader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
31
|
|
|
$bundleResourceLoader->load('services.yml'); |
|
32
|
1 |
|
// $loader->load('parameters.yml'); |
|
33
|
1 |
|
// $loader->load('default_settings.yml'); |
|
34
|
1 |
|
|
|
35
|
|
|
|
|
36
|
1 |
|
$libResourceLoader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../../lib/Resources/config')); |
|
37
|
|
|
$libResourceLoader->load('services.yml'); |
|
38
|
1 |
|
$libResourceLoader->load('parameters.yml'); |
|
39
|
1 |
|
$libResourceLoader->load('default_settings.yml'); |
|
40
|
1 |
|
|
|
41
|
1 |
|
$processor = new ConfigurationProcessor($container, ConfigurationConstants::SETTINGS_ROOT); |
|
42
|
1 |
|
$configArrays = array( |
|
43
|
1 |
|
ConfigurationConstants::ACTIONS, |
|
44
|
1 |
|
ConfigurationConstants::ACTION_CONFIG, |
|
45
|
1 |
|
); |
|
46
|
1 |
|
|
|
47
|
|
|
$scopes = array_merge(array('default'), $container->getParameter('ezpublish.siteaccess.list')); |
|
48
|
1 |
|
|
|
49
|
1 |
|
foreach ($configArrays as $configArray) { |
|
50
|
1 |
|
$processor->mapConfigArray($configArray, $config); |
|
51
|
1 |
|
foreach ($scopes as $scope) { |
|
52
|
1 |
|
$paramName = ConfigurationConstants::SETTINGS_ROOT . '.' . $scope . '.' . $configArray; |
|
53
|
|
|
if (!$container->hasParameter($paramName)) { |
|
54
|
|
|
continue; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$scopeConfig = $container->getParameter($paramName); |
|
58
|
|
|
foreach ((array) $scopeConfig as $key => $value) { |
|
59
|
|
|
$container->setParameter($paramName . '.' . $key, $value); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function prepend(ContainerBuilder $container) |
|
66
|
|
|
{ |
|
67
|
|
|
$configs = array( |
|
68
|
|
|
'twig.yml' => 'twig', |
|
69
|
|
|
); |
|
70
|
|
|
|
|
71
|
|
|
$activatedBundles = array_keys($container->getParameter('kernel.bundles')); |
|
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
foreach ($configs as $fileName => $extensionName) { |
|
74
|
|
|
$configFile = __DIR__ . '/../../lib/Resources/config/' . $fileName; |
|
75
|
|
|
$config = Yaml::parse(file_get_contents($configFile)); |
|
76
|
|
|
$container->prependExtensionConfig($extensionName, $config); |
|
77
|
|
|
$container->addResource(new FileResource($configFile)); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.