Autowire
Registry-backed property dependency injection.
Purpose & processing
Injects the object returned by Core\Registry::get(). If no object is registered, the Registry may create and register it; a missing registration does not imply null.
Parameters
| Parameter | Type | Default | Behavior |
|---|---|---|---|
| class | string | Required | Fully qualified class name to resolve through the Registry. |
Example
#[Autowire(MyService::class)]
protected MyService|null $service = null;Behavior and considerations
- The Registry applies its normal class mapping, extension and shared-object rules.
- An existing non-null property value is preserved.
- An unresolvable class raises a RegistryException.
Source
shared/src/Core/Annotation/Autowire.php