Skip to content

Commit 7d3b0f8

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: Fix code example about prepend config
2 parents 20e58ba + 1a79075 commit 7d3b0f8

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

bundles/prepend_extension.rst

+10-14
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,18 @@ in case a specific other bundle is not registered::
8080
}
8181
}
8282

83-
// process the configuration of AcmeHelloExtension
83+
// get the configuration of AcmeHelloExtension (it's a list of configuration)
8484
$configs = $container->getExtensionConfig($this->getAlias());
8585

86-
// resolve config parameters e.g. %kernel.debug% to its boolean value
87-
$resolvingBag = $container->getParameterBag();
88-
$configs = $resolvingBag->resolveValue($configs);
89-
90-
// use the Configuration class to generate a config array with
91-
// the settings "acme_hello"
92-
$config = $this->processConfiguration(new Configuration(), $configs);
93-
94-
// check if entity_manager_name is set in the "acme_hello" configuration
95-
if (isset($config['entity_manager_name'])) {
96-
// prepend the acme_something settings with the entity_manager_name
97-
$config = ['entity_manager_name' => $config['entity_manager_name']];
98-
$container->prependExtensionConfig('acme_something', $config);
86+
// iterate in reverse to preserve the original order after prepending the config
87+
foreach (array_reverse($configs) as $config) {
88+
// check if entity_manager_name is set in the "acme_hello" configuration
89+
if (isset($config['entity_manager_name'])) {
90+
// prepend the acme_something settings with the entity_manager_name
91+
$container->prependExtensionConfig('acme_something', [
92+
'entity_manager_name' => $config['entity_manager_name'],
93+
]);
94+
}
9995
}
10096
}
10197

0 commit comments

Comments
 (0)