PHP Класс Webiny\Component\EventManager\EventManager

Наследование: use trait Webiny\Component\StdLib\StdLibTrait, use trait Webiny\Component\StdLib\SingletonTrait
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
disable ( ) Disable event handling
enable ( ) Enable event handling
fire ( string $eventName, array | Event $data = null, null $resultType = null, null | integer $limit = null ) : array Fire event
getEventListeners ( $eventName ) : array Get array of event listeners
listen ( string $eventName, EventListener $eventListener = null ) : EventListener Subscribe to event
subscribe ( Webiny\Component\EventManager\EventSubscriberInterface $subscriber ) Subscribe to events using event subscriber

Защищенные методы

Метод Описание
init ( ) Singleton constructor

Приватные методы

Метод Описание
fireWildcardEvents ( $eventName, $data, $resultType ) : null | array Process events starting with given prefix (ex: webiny.* will process all events starting with 'webiny.')

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

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

After calling this method EventManager will ignore all fired events.
public disable ( )

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

After calling this method EventManager will process all fired events.
public enable ( )

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

Fire event
public fire ( string $eventName, array | Event $data = null, null $resultType = null, null | integer $limit = null ) : array
$eventName string Event to fire. You can also use wildcards to fire multiple events at once, ex: 'event.*'
$data array | Event Array or Event object
$resultType null If specified, the event results will be filtered using given class/interface name
$limit null | integer Number of results to return
Результат array Array of results from EventListeners

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

Get array of event listeners
public getEventListeners ( $eventName ) : array
$eventName
Результат array

init() защищенный Метод

Singleton constructor
protected init ( )

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

Subscribe to event
public listen ( string $eventName, EventListener $eventListener = null ) : EventListener
$eventName string Event name you want to listen
$eventListener EventListener (Optional) If specified, given EventListener will be used for this event
Результат EventListener Return instance of EventListener

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

Subscribe to events using event subscriber
public subscribe ( Webiny\Component\EventManager\EventSubscriberInterface $subscriber )
$subscriber Webiny\Component\EventManager\EventSubscriberInterface Subscriber class