mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW: Allow “%$” prefix in Injector::get()
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.
This commit is contained in:
parent
0ed1750106
commit
26b9bf11ed
@ -929,6 +929,11 @@ class Injector implements ContainerInterface
|
|||||||
*/
|
*/
|
||||||
protected function getNamedService($name, $asSingleton = true, $constructorArgs = [])
|
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
|
// Normalise service / args
|
||||||
list($name, $constructorArgs) = $this->normaliseArguments($name, $constructorArgs);
|
list($name, $constructorArgs) = $this->normaliseArguments($name, $constructorArgs);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user