ServiceManager
class ServiceManager (View source)
Manage Drush services.
This class manages the various services / plugins supported by Drush. The primary examples of these include:
- Command files
- Hooks
- Symfony Console commands
- Command info alterers
- Generators
Most services are discovered via the PSR-4 discovery mechanism. Legacy services are injected into this object by the bootstrap handler (DrushBoot8) using the LegacyServiceFinder and LegacyServiceInstantiator classes.
Properties
protected string[] | $bootstrapCommandClasses |
Methods
Ensure that any discovered class that is not part of the autoloader is, in fact, included.
Return cached of deferred commandhander objects.
Discover all of the different kinds of command handler objects in the places where Drush can find them. Called during preflight; some command classes are returned right away, and others are saved to be handled later during Drupal bootstrap.
Discover commands explicitly declared in configuration.
Discovers command classes from a provided search path.
Discover PSR-4 autoloaded classes that implement Annotated Command library command handlers.
Discover PSR-4 autoloaded classes that implement DCG generators.
Discover module commands. This is the preferred way to find module commands in Drush 12+.
Discover command info alterers in modules.
Instantiate commands from Grasmash\YamlCli that we want to expose as Drush commands.
Instantiate commands from Drupal Core that we want to expose as Drush commands.
Instantiate objects given a list of classes. For each class, if it has
a static create
factory, use that to instantiate it, passing both the
Drupal and Drush DI containers. If there is no static factory, then
instantiate it via 'new $class'
Determine if the first parameter of the create method supports our container with delegate.
Check to see if the provided class has a static create
method.
Does the provided class have a Bootstrap Attribute, indicating early loading.
Check whether a command class requires Drupal bootstrap.
Check to see if the provided class has the specified static method.
Check to see if the provided class has a static createEarly
method.
Return generators that ship in modules.
Inject any dependencies needed via the "*AwareInterface" pattern
Details
__construct(ClassLoader $autoloader, DrushConfig $config, LoggerInterface $logger)
No description
protected void
loadCommandClasses(array $commandClasses)
Ensure that any discovered class that is not part of the autoloader is, in fact, included.
array
bootstrapCommandClasses()
Return cached of deferred commandhander objects.
array
discover(array $commandfileSearchpath, string $baseNamespace)
Discover all of the different kinds of command handler objects in the places where Drush can find them. Called during preflight; some command classes are returned right away, and others are saved to be handled later during Drupal bootstrap.
array
discoverCommandsFromConfiguration()
Discover commands explicitly declared in configuration.
array
discoverCommands(array $directoryList, string $baseNamespace)
Discovers command classes from a provided search path.
array
discoverPsr4Commands()
Discover PSR-4 autoloaded classes that implement Annotated Command library command handlers.
array
discoverPsr4Generators()
Discover PSR-4 autoloaded classes that implement DCG generators.
array
discoverModuleCommands(array $directoryList, string $baseNamespace)
Discover module commands. This is the preferred way to find module commands in Drush 12+.
array
discoverModuleCommandInfoAlterers(array $directoryList, string $baseNamespace)
Discover command info alterers in modules.
array
instantiateYamlCliCommands()
Instantiate commands from Grasmash\YamlCli that we want to expose as Drush commands.
array
instantiateDrupalCoreBootstrappedCommands()
Instantiate commands from Drupal Core that we want to expose as Drush commands.
These require a bootstrapped Drupal.
array
instantiateServices(array $bootstrapCommandClasses, Container $drushContainer, ContainerInterface|null $container = null)
Instantiate objects given a list of classes. For each class, if it has
a static create
factory, use that to instantiate it, passing both the
Drupal and Drush DI containers. If there is no static factory, then
instantiate it via 'new $class'
protected bool
supportsCompoundContainer($class, $drush_container)
Determine if the first parameter of the create method supports our container with delegate.
protected bool
hasStaticCreateFactory(string $class)
Check to see if the provided class has a static create
method.
protected int|null
bootStrapAttributeValue(string $class)
Does the provided class have a Bootstrap Attribute, indicating early loading.
protected bool
requiresBootstrap(string $class)
Check whether a command class requires Drupal bootstrap.
protected bool
hasStaticMethod(string $class, string $methodName)
Check to see if the provided class has the specified static method.
protected bool
hasStaticCreateEarlyFactory(string $class)
Check to see if the provided class has a static createEarly
method.
array
discoverModuleGenerators(array $directoryList, string $baseNamespace)
Return generators that ship in modules.
void
inflect(Container $container, mixed $object)
Inject any dependencies needed via the "*AwareInterface" pattern