Skip to content

Commit 64ad9e6

Browse files
[DependencyInjection] Prepend extension config with ContainerConfigurator
1 parent 165d541 commit 64ad9e6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

bundles/prepend_extension.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,34 @@ method::
186186

187187
The ``prependExtension()`` method, like ``prepend()``, is called only at compile time.
188188

189+
Alternatively, you can use the ``prepend`` parameter of the
190+
:method:`Symfony\\Component\\DependencyInjection\\Loader\\ContainerConfigurator::extension`
191+
method::
192+
193+
use Symfony\Component\DependencyInjection\ContainerBuilder;
194+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
195+
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
196+
197+
class FooBundle extends AbstractBundle
198+
{
199+
public function prependExtension(ContainerConfigurator $containerConfigurator, ContainerBuilder $containerBuilder): void
200+
{
201+
// ...
202+
203+
$containerConfigurator->extension('framework', [
204+
'cache' => ['prefix_seed' => 'foo/bar'],
205+
], prepend: true);
206+
207+
// ...
208+
}
209+
}
210+
211+
.. versionadded:: 7.1
212+
213+
The ``prepend`` parameter of the
214+
:method:`Symfony\\Component\\DependencyInjection\\Loader\\ContainerConfigurator::extension`
215+
method was added in Symfony 7.1.
216+
189217
More than one Bundle using PrependExtensionInterface
190218
----------------------------------------------------
191219

0 commit comments

Comments
 (0)