From 7562b4844e3773f82890be4b68c82d4d7e8b9683 Mon Sep 17 00:00:00 2001 From: jwillp Date: Tue, 2 Mar 2021 16:06:06 -0500 Subject: [PATCH] [DependencyInjection] Add ContainerConfigurator::compilerPass() to allow specifying compiler passes --- src/Symfony/Component/DependencyInjection/CHANGELOG.md | 1 + .../Loader/Configurator/ContainerConfigurator.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index 1e45c669e89e4..759c6040c9a55 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -10,6 +10,7 @@ CHANGELOG * Add autoconfigurable attributes * Add support for per-env configuration in loaders * Add `ContainerBuilder::willBeAvailable()` to help with conditional configuration + * Add `ContainerConfigurator::compilerPass` PHP-DSL 5.2.0 ----- diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php index 5fc8f5b6c803d..02661b7eee3fa 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php @@ -15,6 +15,8 @@ use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; @@ -63,6 +65,11 @@ final public function import(string $resource, string $type = null, $ignoreError $this->loader->import($resource, $type, $ignoreErrors, $this->file); } + final public function compilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) + { + $this->container->addCompilerPass($pass, $type, $priority); + } + final public function parameters(): ParametersConfigurator { return new ParametersConfigurator($this->container);