PHP Class Imbo\EventManager\EventManager

Author: Christer Edvartsen ([email protected])
Datei anzeigen Open project: imbo/imbo Class Usage Examples

Public Methods

Method Description
addCallbacks ( string $name, array $events, array $users = [] ) : self Add one or more callbacks
addEventHandler ( string $name, mixed $handler, array $params = [] ) : self Register an event handler
addInitializer ( Imbo\EventListener\Initializer\InitializerInterface $initializer ) : self Add an event listener initializer
getHandlerInstance ( string $name ) : Imbo\EventListener\ListenerInterface Get a handler instance
hasListenersForEvent ( string $eventName ) : boolean Whether or not the manager has event listeners that subscribes to a specific event
setEventTemplate ( Imbo\EventManager\EventInterface $event ) : self Set the event template
trigger ( string $eventName, array $params = [] ) : EventManager Trigger a given event

Private Methods

Method Description
getEventNameParts ( string $event ) Get all parts of an event name
getListenersForEvent ( string $event ) : PriorityQueue[] Get all listeners that listens for an event, including wildcard listeners
triggersFor ( string $user = null, array $filter = [] ) : boolean Check if a listener will trigger for a given user

Method Details

addCallbacks() public method

Add one or more callbacks
public addCallbacks ( string $name, array $events, array $users = [] ) : self
$name string The name of the handler that owns the callback
$events array Which events the callback will trigger for
$users array User filter for the events
return self

addEventHandler() public method

Register an event handler
public addEventHandler ( string $name, mixed $handler, array $params = [] ) : self
$name string The name of the handler
$handler mixed The handler itself
$params array Parameters for the handler if $handler is a string
return self

addInitializer() public method

Add an event listener initializer
public addInitializer ( Imbo\EventListener\Initializer\InitializerInterface $initializer ) : self
$initializer Imbo\EventListener\Initializer\InitializerInterface An initializer instance
return self

getHandlerInstance() public method

Get a handler instance
public getHandlerInstance ( string $name ) : Imbo\EventListener\ListenerInterface
$name string The name of the handler
return Imbo\EventListener\ListenerInterface

hasListenersForEvent() public method

Whether or not the manager has event listeners that subscribes to a specific event
public hasListenersForEvent ( string $eventName ) : boolean
$eventName string The name of the event to check
return boolean

setEventTemplate() public method

This event instance will be cloned for each use of the trigger method
public setEventTemplate ( Imbo\EventManager\EventInterface $event ) : self
$event Imbo\EventManager\EventInterface A configured event instance
return self

trigger() public method

Trigger a given event
public trigger ( string $eventName, array $params = [] ) : EventManager
$eventName string The name of the event to trigger
$params array Extra parameters for the event
return EventManager