PHP Класс FOF30\Event\Dispatcher

Наследование: implements FOF30\Event\Observable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$container The container this event dispatcher is attached to
$events Maps events to observers
$observers The observers attached to the dispatcher

Открытые методы

Метод Описание
__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

Описание методов

__construct() публичный Метод

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

attach() публичный Метод

Attaches an observer to the object
public attach ( Observer $observer ) : Dispatcher
$observer Observer The observer to attach
Результат Dispatcher Ourselves, for chaining

chainHandle() публичный Метод

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
Результат mixed Null if the event can't be handled by any observer

detach() публичный Метод

Detaches an observer from the object
public detach ( Observer $observer ) : Dispatcher
$observer Observer The observer to detach
Результат Dispatcher Ourselves, for chaining

getContainer() публичный Метод

Returns the container this event dispatcher is attached to
public getContainer ( ) : Container
Результат FOF30\Container\Container

getObserverByClass() публичный Метод

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
Результат null | Observer

hasObserver() публичный Метод

Is an observer object already registered with this dispatcher?
public hasObserver ( Observer $observer ) : boolean
$observer Observer The observer to check if it's attached
Результат boolean

hasObserverClass() публичный Метод

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
Результат boolean

trigger() публичный Метод

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
Результат array

Описание свойств

$container защищенное свойство

The container this event dispatcher is attached to
protected $container

$events защищенное свойство

Maps events to observers
protected $events

$observers защищенное свойство

The observers attached to the dispatcher
protected $observers