\Ceo\CoreEvent

Simple event management, allows for assigning callbacks instead of full functions to respond to events.

use Ceo\Core\Event;

// Register event handler
Event::register(Event::UPDATE_EVENT, function($emitter, $data) {
 var_export($emitter);
 ...
});

// Create and fire event:
$e = (new Event)
 ->setType(Event::UPDATE_EVENT)
 ->setEmitter($myObject)
 ->setData(['myExtra' => 'stuff'])
 ->fire();

Summary

Methods
Properties
Constants
setEventsManager()
getEventsManager()
register()
unregister()
__construct()
fire()
setEmitter()
setType()
setData()
getEmitter()
getData()
afterCreate()
afterUpdate()
afterDelete()
beforeNull()
No public properties found
UPDATE_EVENT
CREATE_EVENT
DELETE_EVENT
NULL_EVENT
No protected methods found
No protected properties found
N/A
registerCallbacks()
$handlers
$isRegistered
$manager
$emitter
$data
$type
N/A

Constants

UPDATE_EVENT

UPDATE_EVENT

Event::UPDATE_EVENT

CREATE_EVENT

CREATE_EVENT

Event::CREATE_EVENT

DELETE_EVENT

DELETE_EVENT

Event::DELETE_EVENT

NULL_EVENT

NULL_EVENT

Event::NULL_EVENT Empty event endpoint

Properties

$handlers

$handlers : 

Type

$isRegistered

$isRegistered : 

Type

$manager

$manager : 

Type

$emitter

$emitter : 

Type

$data

$data : 

Type

$type

$type : 

Type

Methods

setEventsManager()

setEventsManager(\Ceo\Core\Phalcon\Events\EventsManager  $manager) : void

Set events manager

Parameters

\Ceo\Core\Phalcon\Events\EventsManager $manager

getEventsManager()

getEventsManager() : object

Return events manager, returns default if not set

Returns

object —

Phalcon\Events\EventsManager

register()

register(\Ceo\Core\const  $type, \Ceo\Core\closure  $callback) : string

Register an event callback

Event::register(Event::UPDATE_EVENT, function($emitter, $data) {
...
})

Parameters

\Ceo\Core\const $type
\Ceo\Core\closure $callback

Returns

string —

Event ID

unregister()

unregister(\Ceo\Core\cost  $type, string  $id) : boolean

Un-register a function call

$id = Event::register(Event::UPDATE_EVENT, function($emitter, $data) {
...
});

Event::unregister(Event::UPDATE_EVENT, $id);

Parameters

\Ceo\Core\cost $type
string $id

Returns

boolean

__construct()

__construct() 

fire()

fire() : void

Fire event

setEmitter()

setEmitter(mixed  $emitter) : self

Set the event emitter, e.g. the object that's creating the event

Parameters

mixed $emitter

Returns

self

setType()

setType(\Ceo\Core\const  $type) : self

Set event type

Parameters

\Ceo\Core\const $type

Returns

self

setData()

setData(array  $data) : self

Set extra data to be passed

Parameters

array $data

Returns

self

getEmitter()

getEmitter() : mixed

Return the emitter object

Returns

mixed

getData()

getData() : array

Return extra data

Returns

array

afterCreate()

afterCreate(\Ceo\Core\Event  $event, mixed  $emitter, array  $data = array()) : void

Handles Event::CREATE_EVENT

Parameters

\Ceo\Core\Event $event
mixed $emitter
array $data

afterUpdate()

afterUpdate(\Ceo\Core\Event  $event, mixed  $emitter, array  $data = array()) : void

Handles Event::UPDATE_EVENT

Parameters

\Ceo\Core\Event $event
mixed $emitter
array $data

afterDelete()

afterDelete(\Ceo\Core\Event  $event, mixed  $emitter, array  $data = array()) : void

Handles Event::DELETE_EVENT

Parameters

\Ceo\Core\Event $event
mixed $emitter
array $data

beforeNull()

beforeNull(\Ceo\Core\Event  $event, mixed  $emitter, array  $data = array()) : void

Handles Event::NULL_EVENT which doesn't fire anything

Parameters

\Ceo\Core\Event $event
mixed $emitter
array $data

registerCallbacks()

registerCallbacks() : void

Register callbacks