Phalcon events
NOTE
All classes are prefixed with Phalcon
Events\AbstractEventsAware ¶
-
Namespace
Phalcon\Events
-
Uses
Phalcon\Events\ManagerInterface
-
Extends
-
Implements
This abstract class offers access to the events manager
Properties¶
Methods¶
Returns the internal event manager Sets the events managerprotected function fireManagerEvent( string $eventName, mixed $data = null, bool $cancellable = bool ): mixed | bool;
Events\Event¶
-
Namespace
Phalcon\Events
-
Uses
-
Extends
-
Implements
EventInterface
This class offers contextual information of a fired event in the EventsManager
Phalcon\Events\Event;
$event = new Event("db:afterQuery", $this, ["data" => "mydata"], true);
if ($event->isCancelable()) {
$event->stop();
}
Properties¶
/**
* Is event cancelable?
*
* @var bool
*/
protected $cancelable;
/**
* Event data
*
* @var mixed
*/
protected $data;
/**
* Event source
*
* @var object|null
*/
protected $source;
/**
* Is event propagation stopped?
*
* @var bool
*/
protected $stopped = false;
/**
* Event type
*
* @var string
*/
protected $type;
Methods¶
public function __construct( string $type, mixed $source = null, mixed $data = null, bool $cancelable = bool );
Events\EventInterface ¶
-
Namespace
Phalcon\Events
-
Uses
-
Extends
-
Implements
Interface for Phalcon\Events\Event class
Methods¶
Gets event data Gets event type Check whether the event is cancelable Check whether the event is currently stopped Sets event data Sets event type Stops the event preventing propagationEvents\EventsAwareInterface ¶
-
Namespace
Phalcon\Events
-
Uses
-
Extends
-
Implements
This interface must for those classes that accept an EventsManager and dispatch events
Methods¶
Returns the internal event manager Sets the events managerEvents\Exception¶
-
Namespace
Phalcon\Events
-
Uses
-
Extends
\Exception
-
Implements
Exceptions thrown in Phalcon\Events will use this class
Events\Manager¶
-
Namespace
Phalcon\Events
-
Uses
Closure
SplPriorityQueue
-
Extends
-
Implements
ManagerInterface
Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed, the normal flow of operation. With the EventsManager the developer can create hooks or plugins that will offer monitoring of data, manipulation, conditional execution and much more.
Constants¶
Properties¶
/**
* @var bool
*/
protected $collect = false;
/**
* @var bool
*/
protected $enablePriorities = false;
/**
* @var array
*/
protected $events;
/**
* @var array
*/
protected $responses;
Methods¶
Returns if priorities are enabledpublic function attach( string $eventType, mixed $handler, int $priority = static-constant-access ): void;
A priority queue of events is a data structure similar to a regular queue of events: we can also put and extract elements from it. The difference is that each element in a priority queue is associated with a value called priority. This value is used to order elements of a queue: elements with higher priority are retrieved before the elements with lower priority.
public function fire( string $eventType, object $source, mixed $data = null, bool $cancelable = bool );
Events\ManagerInterface ¶
-
Namespace
Phalcon\Events
-
Uses
-
Extends
-
Implements
Interface for Phalcon\Events managers.