Observer
in package
Registers a method as an event observer.
Compiled at composer dump-autoload into vendor/composer/maho_attributes.php.
Run composer dump-autoload after adding, modifying, or removing this attribute.
This attribute is repeatable — apply multiple times to listen to different events or areas.
Tags
Attributes
- #[Attribute]
- \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE
Table of Contents
Properties
Methods
- __construct() : mixed
Properties
$area
public
string
$area
= 'global'
$event
public
string
$event
$id
public
string|null
$id
= null
$replaces
public
string|null
$replaces
= null
$type
public
string
$type
= 'model'
Methods
__construct()
public
__construct(string $event[, string $area = 'global' ][, string $type = 'model' ][, string|null $id = null ][, string|null $replaces = null ]) : mixed
Parameters
- $event : string
-
Event name to observe (e.g. 'catalog_product_save_after')
- $area : string = 'global'
-
Area scope: 'global' (default), 'frontend', 'adminhtml', 'crontab', 'install'
- $type : string = 'model'
-
Instantiation type: 'model' (default, new instance per dispatch) or 'singleton' (shared instance)
- $id : string|null = null
-
Observer identifier, auto-generated if omitted. Set explicitly when other code references this observer by id.
- $replaces : string|null = null
-
The
idof another observer on the same event/area to disable and replace. Accepts either the explicit id, the class name, or the class alias format (e.g.'my_observer','Mage_Catalog_Model_Observer::myMethod', or'catalog/observer::myMethod').