PHP Class FOF30\Event\Dispatcher

Inheritance: implements FOF30\Event\Observable
Datei anzeigen Open project: akeeba/fof Class Usage Examples

Protected Properties

Property Type Description
$container The container this event dispatcher is attached to
$events Maps events to observers
$observers The observers attached to the dispatcher

Public Methods

Method Description
__construct ( Container $container ) Public constructor
attach ( Observer $observer ) : Dispatcher Attaches an observer to the object
chainHandle ( string $event, array $args = [] ) : mixed Asks each observer to handle an event based on the provided arguments. The first observer to return a non-null result wins. This is a *very* simplistic implementation of the Chain of Command pattern.
detach ( Observer $observer ) : Dispatcher Detaches an observer from the object
getContainer ( ) : Container Returns the container this event dispatcher is attached to
getObserverByClass ( string $className ) : null | Observer Returns an observer attached to this behaviours dispatcher by its class name
hasObserver ( Observer $observer ) : boolean Is an observer object already registered with this dispatcher?
hasObserverClass ( string $className ) : boolean Is there an observer of the specified class already registered with this dispatcher?
trigger ( string $event, array $args = [] ) : array Triggers an event in the attached observers

Method Details

__construct() public method

Public constructor
public __construct ( Container $container )
$container FOF30\Container\Container The container this event dispatcher is attached to

attach() public method

Attaches an observer to the object
public attach ( Observer $observer ) : Dispatcher
$observer Observer The observer to attach
return Dispatcher Ourselves, for chaining

chainHandle() public method

Asks each observer to handle an event based on the provided arguments. The first observer to return a non-null result wins. This is a *very* simplistic implementation of the Chain of Command pattern.
public chainHandle ( string $event, array $args = [] ) : mixed
$event string The event name to handle
$args array The arguments to the event
return mixed Null if the event can't be handled by any observer

detach() public method

Detaches an observer from the object
public detach ( Observer $observer ) : Dispatcher
$observer Observer The observer to detach
return Dispatcher Ourselves, for chaining

getContainer() public method

Returns the container this event dispatcher is attached to
public getContainer ( ) : Container
return FOF30\Container\Container

getObserverByClass() public method

Returns an observer attached to this behaviours dispatcher by its class name
public getObserverByClass ( string $className ) : null | Observer
$className string The class name of the observer object to return
return null | Observer

hasObserver() public method

Is an observer object already registered with this dispatcher?
public hasObserver ( Observer $observer ) : boolean
$observer Observer The observer to check if it's attached
return boolean

hasObserverClass() public method

Is there an observer of the specified class already registered with this dispatcher?
public hasObserverClass ( string $className ) : boolean
$className string The observer class name to check if it's attached
return boolean

trigger() public method

Triggers an event in the attached observers
public trigger ( string $event, array $args = [] ) : array
$event string The event to attach
$args array Arguments to the event handler
return array

Property Details

$container protected_oe property

The container this event dispatcher is attached to
protected $container

$events protected_oe property

Maps events to observers
protected $events

$observers protected_oe property

The observers attached to the dispatcher
protected $observers