Skip to content

Commit 93f8509

Browse files
committed
add argument to prepend extension config
1 parent 71c053f commit 93f8509

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.1
5+
---
6+
7+
* Add argument `$prepend` to `ContainerConfigurator::extension()` to prepend the configuration instead of appending it
8+
49
7.0
510
---
611

Loader/Configurator/ContainerConfigurator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ public function __construct(ContainerBuilder $container, PhpFileLoader $loader,
4848
$this->env = $env;
4949
}
5050

51-
final public function extension(string $namespace, array $config): void
51+
final public function extension(string $namespace, array $config, bool $prepend = false): void
5252
{
53+
if ($prepend) {
54+
$this->container->prependExtensionConfig($namespace, static::processValue($config));
55+
56+
return;
57+
}
58+
5359
if (!$this->container->hasExtension($namespace)) {
5460
$extensions = array_filter(array_map(fn (ExtensionInterface $ext) => $ext->getAlias(), $this->container->getExtensions()));
5561
throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $this->file, $namespace, $extensions ? implode('", "', $extensions) : 'none'));

Tests/Extension/AbstractExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function prependExtension(ContainerConfigurator $container, ContainerBuil
6363
$container->extension('third', ['foo' => 'append']);
6464

6565
// prepend config
66-
$builder->prependExtensionConfig('third', ['foo' => 'prepend']);
66+
$container->extension('third', ['foo' => 'prepend'], true);
6767
}
6868
};
6969

0 commit comments

Comments
 (0)