From 26b9bf11edcc2cb5a27a681ab52ad0f8299df81a Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 23 Jun 2017 11:15:51 +1200 Subject: [PATCH] =?UTF-8?q?NEW:=20Allow=20=E2=80=9C%$=E2=80=9D=20prefix=20?= =?UTF-8?q?in=20Injector::get()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injector::get() looks up services by name. In yaml config it can make things clearer to prefix service names by %$, which is how they must be prefixed when referencing nested services within service definitions. This change means that any other system referencing services will support an optional prefix without needing to specifically code support in themselves. --- src/Core/Injector/Injector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Core/Injector/Injector.php b/src/Core/Injector/Injector.php index 6b3f28abd..8b68f5aef 100644 --- a/src/Core/Injector/Injector.php +++ b/src/Core/Injector/Injector.php @@ -929,6 +929,11 @@ class Injector implements ContainerInterface */ protected function getNamedService($name, $asSingleton = true, $constructorArgs = []) { + // Allow service names of the form "%$ServiceName" + if (substr($name, 0, 2) == '%$') { + $name = substr($name, 2); + } + // Normalise service / args list($name, $constructorArgs) = $this->normaliseArguments($name, $constructorArgs);