LegacyServiceInstantiator
class LegacyServiceInstantiator (View source)
Use the Symfony Dependency Injection Container to instantiate services.
This factory class is used solely for backwards compatability with
Drupal modules that still use drush.services.ymls to define Drush
Commands, Generators & etc.; this mechanism is deprecated, though.
Modules should instead use the static factory create
mechanism.
This object is only in scope during bootstrap; see the DrupalBoot8 class. After it has been used there, it is not referenced by any other code.
Properties
protected array | $instantiatedDrushServices | ||
protected array | $tags |
Methods
No description
Instantiate all of the objects declared by drush.services.yml files, and store them internally in this class for later retreival by type.
Validate service data before using it.
Check all elements for required "class" elements.
Given a drush.services.yml file (parsed into an array), instantiate all of the services referenced therein.
After instantiateServices()
runs, the resulting instantiated
service objects can be retrieved via this method.
Create one named service.
Instantiate an object with the given arguments.
Call a method of an object with the provided arguments.
Resolve arguments against our containers. Arguments that do not map to one of our containers are returned unchanged.
Look up one argument in the appropriate container, or return it as-is.
Look up in the provided container; throw an exception if
not found, unless the service name begins with ?
(e.g.
Check to see if the provided argument begins with a ?
;
those that do not are required.
Helper function to determine whether or not any of the arguments
resolved. set
methods with non-required DI container references
are not called at all if the optional references are not in the container.
Details
__construct(ContainerInterface $container, LoggerInterface $logger)
No description
loadServiceFiles(array $serviceFiles)
Instantiate all of the objects declared by drush.services.yml files, and store them internally in this class for later retreival by type.
protected bool
isValidServiceData(string $serviceFile, array $serviceFileData)
Validate service data before using it.
protected bool
allServicesHaveClassElement(string $serviceFile, array $services)
Check all elements for required "class" elements.
instantiateServices(array $services)
Given a drush.services.yml file (parsed into an array), instantiate all of the services referenced therein.
The services created may be retrieved via the taggedServices()
method.
object[]
taggedServices(string $tagName)
After instantiateServices()
runs, the resulting instantiated
service objects can be retrieved via this method.
object|null
create(string $class, array $arguments, array $calls)
Create one named service.
instantiateObject(string $class, array $arguments)
Instantiate an object with the given arguments.
Arguments are first looked up from the Drupal container
or from our dynamic service container if they begin
with an @
.
call(object $object, string $method, array $arguments)
Call a method of an object with the provided arguments.
Arguments are resolved against the container first.
protected array
resolveArguments(array $arguments)
Resolve arguments against our containers. Arguments that do not map to one of our containers are returned unchanged.
protected mixed
resolveArgument($arg)
Look up one argument in the appropriate container, or return it as-is.
protected ?object
resolveFromContainer(Container $container, string $arg)
Look up in the provided container; throw an exception if
not found, unless the service name begins with ?
(e.g.
@?drupal.service
or *?drush.service
).
protected array
isRequired(string $arg)
Check to see if the provided argument begins with a ?
;
those that do not are required.
protected bool
atLeastOneValue(array $args)
Helper function to determine whether or not any of the arguments
resolved. set
methods with non-required DI container references
are not called at all if the optional references are not in the container.