DispatcherAttacher
API reference › Debug › service › DispatcherAttacher
Hands every collector named in Module::$dispatchers to the application component the application pairs it
with, so the component emits its PSR-14 events into the collector.
The way the component takes the collector is detected, never declared: a public eventDispatcher property (or a Yii
getter/setter pair) wins, then a constructor parameter named eventDispatcher. A definition is amended without
instantiating the component; an instantiated component only accepts the property form. A dispatcher the component
already configures is kept, so a populated application dispatcher is never replaced by the collector.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$module protected readonly constructor | yii\ | Debug module owning the dispatcher map and the collector coordinator, read at call time. | DispatcherAttacher |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Binds dispatcher attachment to the module’s collectors and component map. | DispatcherAttacher |
attach() | Attaches every configured collector to its application component. | DispatcherAttacher |
dispatcherArgumentKey() protected | Returns the __construct() key a component definition takes its dispatcher under. | DispatcherAttacher |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(yii\debug\Module $module)Binds dispatcher attachment to the module’s collectors and component map.
Parameters
| Parameter | Type | Description |
|---|---|---|
$module | yii\ | Debug module owning the dispatcher map and the collector coordinator, read at call time. |
attach()
Section titled “attach() ”public function attach(yii\base\Application $app): voidAttaches every configured collector to its application component.
Runs once every bootstrap class had its turn, so a component a bootstrap class registers is seen. A collector
disabled through enabled => false is skipped; CollectorRegistrar already rejected an entry naming no
configured collector.
Parameters
| Parameter | Type | Description |
|---|---|---|
$app | yii\ | Application owning the components. |
Throws
yii\base\InvalidConfigException: when a collector is not a PSR-14 dispatcher, or when its component is unknown, instantiated without a writableeventDispatcherproperty, or unable to take the collector.
dispatcherArgumentKey()
Section titled “dispatcherArgumentKey() ”protected function dispatcherArgumentKey(class-string $class, array<array-key, mixed> $arguments): int|string|nullReturns the __construct() key a component definition takes its dispatcher under.
A definition indexing its arguments by position gets the dispatcher at the position its constructor declares, because Yii rejects a definition mixing named and positional arguments; every other definition gets it by name.
Override point: a subclass returning its own key attaches the collector to a component whose constructor names the dispatcher parameter differently.
Parameters
| Parameter | Type | Description |
|---|---|---|
$class | class-string | Component class whose constructor is inspected. |
$arguments | array<array-key, | Arguments the definition already declares. |
Returns
int|string|null: Key to write the dispatcher under, or null when the constructor declares no eventDispatcher parameter.