PHP Class Pheasant\Events

Show file Open project: lox/pheasant Class Usage Examples

Public Methods

Method Description
__construct ( $handlers = [], $upstream = null ) Construct
__invoke ( $event, $object )
cork ( ) Prevent events from firing until uncork() is called
discard ( ) Discards any events queued with cork()
register ( $event, $callback ) Registers a handler for an event
trigger ( $event, $object ) Triggers an event against the registered handlers
uncork ( ) Execute events that have been queued since cork() was called
unregister ( $event = null ) Unregisters an event handler based on event, or all
wrap ( $event, $object, $callback ) Execute a closure, trigger a before{$event} and after{$event}

Private Methods

Method Description
_callbacksFor ( $event )

Method Details

__construct() public method

Construct
public __construct ( $handlers = [], $upstream = null )

__invoke() public method

See also: http://www.php.net/manual/en/language.oop5.magic.php#object.invoke
public __invoke ( $event, $object )

cork() public method

Prevent events from firing until uncork() is called
public cork ( )

discard() public method

Discards any events queued with cork()
public discard ( )

register() public method

Registers a handler for an event
public register ( $event, $callback )

trigger() public method

Triggers an event against the registered handlers
public trigger ( $event, $object )

uncork() public method

Execute events that have been queued since cork() was called
public uncork ( )

unregister() public method

Unregisters an event handler based on event, or all
public unregister ( $event = null )

wrap() public method

Execute a closure, trigger a before{$event} and after{$event}
public wrap ( $event, $object, $callback )