Skip to content
docsv0.8.0

Subscribe

Marks a class or method as an event subscriber. Can be applied to: - Classes: The class becomes a listener, method specified by $method parameter - Methods: The method becomes the event handler

Subscribe::__construct()

public function __construct(string $event, ?string $method = null, Milpa\Enums\ListenerPriority|int $priority = Milpa\Enums\ListenerPriority::NORMAL, ?Milpa\Enums\DispatcherType $dispatcher = null):

Parameters

Parameters of __construct()
NameTypeDescription
$eventstringEvent name or class to subscribe to
$method(string | null)Handler method name (required for class-level)
$priority(int | ListenerPriority)Execution priority (higher = earlier)
$dispatcher(DispatcherType | null)Target event bus (DispatcherType::SYMFONY or DispatcherType::MILPA)

Subscribe::getPriority()

public function getPriority(): int

Get the numeric priority value.