From a32afb34918e091492561f893ed6bb03415f1315 Mon Sep 17 00:00:00 2001 From: Drush Documentation Bot Date: Sat, 9 Mar 2024 22:17:15 +0000 Subject: [PATCH] Deployed 7a27c1b47 to 12.x with MkDocs 1.4.3 and mike 2.0.0 --- 12.x/commands/index.html | 2 +- 12.x/dependency-injection/index.html | 10 ++++------ 12.x/search/search_index.json | 2 +- 12.x/site-alias-manager/index.html | 2 +- 12.x/sitemap.xml.gz | Bin 1865 -> 1865 bytes versions.json | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/12.x/commands/index.html b/12.x/commands/index.html index 2c6c6a9bd2..1ca3b764ce 100644 --- a/12.x/commands/index.html +++ b/12.x/commands/index.html @@ -5269,7 +5269,7 @@

Creating Custom Commands

Tip

    -
  1. You may now use Autowire to inject Drupal and Drush dependencies. Prior approaches were using a [create() method](dependency-injection.md#create-method and using a drush.services.yml file. These are now deprecated.
  2. +
  3. You may now use Autowire to inject Drupal and Drush dependencies. Prior approaches were using a [create() method](dependency-injection.md#create-method] and using a drush.services.yml file. These are now deprecated.
  4. Drush 12 expects all commandfiles in the <module-name>/src/Drush/<Commands|Generators> directory. The Drush subdirectory is a new requirement.
diff --git a/12.x/dependency-injection/index.html b/12.x/dependency-injection/index.html index ee3372b111..0e514fcf25 100644 --- a/12.x/dependency-injection/index.html +++ b/12.x/dependency-injection/index.html @@ -5258,8 +5258,8 @@

Dependency Injectiondependency injection via a drush.services.yml file. This approach is deprecated in Drush 12+.

Autowire

-

12.5+ -Command files may inject Drush and Drupal services by adding the AutowireTrait to the class (example: PmCommands). This enables your Constructor parameter type hints determine the the injected service. When a type hint is insufficient, an #[Autowire] Attribute on the constructor property (with service: named argument) directs AutoWireTrait to the right service (example: LoginCommands). This Attribute is currently required when injecting Drush services (not required for Drupal services).

+

12.5+

+

Command files may inject Drush and Drupal services by adding the AutowireTrait to the class (example: PmCommands). This enables your Constructor parameter type hints determine the the injected service. When a type hint is insufficient, an #[Autowire] Attribute on the constructor property (with service: named argument) directs AutoWireTrait to the right service (example: LoginCommands). This Attribute is currently required when injecting Drush services (not required for Drupal services).

If your command is not found by Drush, add the -vvv option for debug info about any service instantiation errors. If Autowire is still insufficient, a commandfile may implement its own create() method (see below).

create() method

11.6+

@@ -5281,13 +5281,11 @@

create() methodDrupal Documentation for details on how to inject Drupal services into your command file. This approach mimics Drupal's blocks, forms, and controllers.

createEarly() method

12.0+

-
-

Tip

-

The createEarly() method was deprecated in Drush 12.5. Instead put a #[CLI\Bootstrap(DrupalBootLevels::NONE)] Attribute on the command class and inject dependencies via the usual __construct with AutowireTrait. Note also that Drush commands packaged with Drupal modules are not discovered +

The createEarly() method was deprecated in Drush 12.5. Instead put a #[CLI\Bootstrap(DrupalBootLevels::NONE)] Attribute on the command class and inject dependencies via the usual __construct with AutowireTrait.

+

Note also that Drush commands packaged with Drupal modules are not discovered until after Drupal bootstraps, and therefore cannot use createEarly(). This mechanism is only usable by PSR-4 discovered commands packaged with Composer projects that are not Drupal modules.

-

Inflection

A command class may implement the following interfaces. When doing so, implement the corresponding trait to satisfy the interface.