Sections

Class Phalcon\Events\Event

Source on GitHub

Namespace Phalcon\Events   Implements EventInterface

Phalcon\Events\Event

This class offers contextual information of a fired event in the EventsManager

Properties

/**
 * Is event cancelable?
 *
 * @var bool
 */
protected cancelable;

/**
 * Event data
 *
 * @var mixed
 */
protected data;

/**
 * Event source
 *
 * @var object
 */
protected source;

/**
 * Is event propagation stopped?
 *
 * @var bool
 */
protected stopped = false;

/**
 * Event type
 *
 * @var string
 */
protected type;

Metody

public function __construct( string $type, mixed $source, mixed $data = null, bool $cancelable = bool ): void;

Phalcon\Events\Event constructor

public function getData(): mixed
public function getSource(): object
public function getType(): string
public function isCancelable(): bool;

Check whether the event is cancelable.

if ($event->isCancelable()) {
    $event->stop();
}
public function isStopped(): bool;

Check whether the event is currently stopped.

public function setData( mixed $data = null ): EventInterface;

Sets event data.

public function setType( string $type ): EventInterface;

Sets event type.

public function stop(): EventInterface;

Stops the event preventing propagation.

if ($event->isCancelable()) {
    $event->stop();
}

Interface Phalcon\Events\EventInterface

Source on GitHub

Namespace Phalcon\Events

Phalcon\Events\EventInterface

Interface for Phalcon\Events\Event class

Metody

public function getData(): mixed;

Gets event data

public function getType(): mixed;

Gets event type

public function isCancelable(): bool;

Check whether the event is cancelable

public function isStopped(): bool;

Check whether the event is currently stopped

public function setData( mixed $data = null ): EventInterface;

Sets event data

public function setType( string $type ): EventInterface;

Sets event type

public function stop(): EventInterface;

Stops the event preventing propagation

Interface Phalcon\Events\EventsAwareInterface

Source on GitHub

Namespace Phalcon\Events

Phalcon\Events\EventsAwareInterface

This interface must for those classes that accept an EventsManager and dispatch events

Metody

public function getEventsManager(): ManagerInterface;

Returns the internal event manager

public function setEventsManager( ManagerInterface $eventsManager ): void;

Sets the events manager

Class Phalcon\Events\Exception

Source on GitHub

Namespace Phalcon\Events   Extends \Phalcon\Exception

Phalcon\Events\Exception

Exceptions thrown in Phalcon\Events will use this class

Class Phalcon\Events\Manager

Source on GitHub

Namespace Phalcon\Events   Uses Closure, Phalcon\Events\Event, SplPriorityQueue   Implements ManagerInterface

Phalcon\Events\Manager

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

const DEFAULT_PRIORITY = 100;

Properties

/**
 * @var bool
 */
protected collect = false;

/**
 * @var bool
 */
protected enablePriorities = false;

//
protected events;

//
protected responses;

Metody

public function arePrioritiesEnabled(): bool;

Returns if priorities are enabled

public function attach( string $eventType, mixed $handler, int $priority = static-constant-access ): void;

Attach a listener to the events manager

public function collectResponses( bool $collect ): void;

Tells the event manager if it needs to collect all the responses returned by every registered listener in a single fire

public function detach( string $eventType, mixed $handler ): void;

Detach the listener from the events manager

public function detachAll( string $type = null ): void;

Removes all events from the EventsManager

public function enablePriorities( bool $enablePriorities ): void;

Set if priorities are enabled in the EventsManager

public function fire( string $eventType, mixed $source, mixed $data = null, bool $cancelable = bool );

Fires an event in the events manager causing the active listeners to be notified about it

$eventsManager->fire("db", $connection);

@return mixed

final public function fireQueue( SplPriorityQueue $queue, EventInterface $event );

Internal handler to call a queue of events

@return mixed

public function getListeners( string $type ): array;

Returns all the attached listeners of a certain type

public function getResponses(): array;

Returns all the responses returned by every handler executed by the last ‘fire’ executed

public function hasListeners( string $type ): bool;

Check whether certain type of event has listeners

public function isCollecting(): bool;

Check if the events manager is collecting all all the responses returned by every registered listener in a single fire

Interface Phalcon\Events\ManagerInterface

Source on GitHub

Namespace Phalcon\Events

Phalcon\Events\Manager

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.

Metody

public function attach( string $eventType, mixed $handler ): void;

Attach a listener to the events manager

public function detach( string $eventType, mixed $handler ): void;

Detach the listener from the events manager

public function detachAll( string $type = null ): void;

Removes all events from the EventsManager

public function fire( string $eventType, mixed $source, mixed $data = null );

Fires an event in the events manager causing the active listeners to be notified about it

@return mixed

public function getListeners( string $type ): array;

Returns all the attached listeners of a certain type

public function hasListeners( string $type ): bool;

Check whether certain type of event has listeners