PHP Trait PHPDaemon\Traits\EventHandlers

Author: Vasily Zorin ([email protected])
Datei anzeigen Open project: kakserpom/phpdaemon

Protected Properties

Property Type Description
$addThisToEvents Unshift $this to arguments of callback?
$eventHandlers Event handlers
$lastEventName Last called event name

Public Methods

Method Description
bind ( string | array $event, callable $cb ) : this Bind event or events
event ( string $name, $args ) : this Propagate event
getLastEventName ( ) : string Use it to define event name, when one callback was bind to more than one events
off ( string | array $event, callable $cb = null ) : this Unbind event(s) or callback from event(s)
on ( string | array $event, callable $cb ) : this Bind event or events
trigger ( string $name, $args ) : this Propagate event
triggerAndCount ( string $name, $args ) : integer Propagate event
unbind ( string | array $event, callable $cb = null ) : this Unbind event(s) or callback from event(s)

Protected Methods

Method Description
cleanupEventHandlers ( ) : void Clean up all events

Method Details

bind() public method

Bind event or events
public bind ( string | array $event, callable $cb ) : this
$event string | array Event name
$cb callable Callback
return this

cleanupEventHandlers() protected method

Clean up all events
protected cleanupEventHandlers ( ) : void
return void

event() public method

Propagate event
public event ( string $name, $args ) : this
$name string Event name
$args Arguments
return this

getLastEventName() public method

Use it to define event name, when one callback was bind to more than one events
public getLastEventName ( ) : string
return string

off() public method

Unbind event(s) or callback from event(s)
public off ( string | array $event, callable $cb = null ) : this
$event string | array Event name
$cb callable Callback, optional
return this

on() public method

Bind event or events
public on ( string | array $event, callable $cb ) : this
$event string | array Event name
$cb callable Callback
return this

trigger() public method

Propagate event
public trigger ( string $name, $args ) : this
$name string Event name
$args Arguments
return this

triggerAndCount() public method

Propagate event
public triggerAndCount ( string $name, $args ) : integer
$name string Event name
$args Arguments
return integer

unbind() public method

Unbind event(s) or callback from event(s)
public unbind ( string | array $event, callable $cb = null ) : this
$event string | array Event name
$cb callable Callback, optional
return this

Property Details

$addThisToEvents protected_oe property

Unshift $this to arguments of callback?
protected $addThisToEvents

$eventHandlers protected_oe property

Event handlers
protected $eventHandlers

$lastEventName protected_oe property

Last called event name
protected $lastEventName