Skip to content

EventsAwareTrait

The EventsAwareTrait provides methods for managing events within a class.

  • Full name: \Zemit\Events\EventsAwareTrait

Properties

eventsPrefix

Event prefix to use as a component my-component:beforeSomeTask my-component:afterSomeTask

public static ?string $eventsPrefix
  • This property is static.

eventsManager

The event manager responsible for handling and triggering events.

protected ?\Phalcon\Events\ManagerInterface $eventsManager

Methods

setEventsManager

Set the events manager

public setEventsManager(\Phalcon\Events\ManagerInterface $manager): void

Parameters:

Parameter Type Description
$manager \Phalcon\Events\ManagerInterface

getEventsManager

Get the events manager.

public getEventsManager(): ?\Phalcon\Events\ManagerInterface

getEventsPrefix

Get the event component prefix

public static getEventsPrefix(): string|null
  • This method is static.

Return Value:

The event component prefix, or null if not set


setEventsPrefix

Sets the events prefix.

public static setEventsPrefix(string|null $eventsPrefix): void
  • This method is static.

Parameters:

Parameter Type Description
$eventsPrefix **string null**

fire

Fire an event.

public fire(string $task, mixed|null $data = null, bool $cancelable = false): mixed

Parameters:

Parameter Type Description
$task string The task to execute.
$data **mixed null**
$cancelable bool Whether the event is cancelable or not. Defaults to false.