PHP Class Webiny\Component\EventManager\EventManager

Inheritance: use trait Webiny\Component\StdLib\StdLibTrait, use trait Webiny\Component\StdLib\SingletonTrait
显示文件 Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
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

Protected Methods

Method Description
init ( ) Singleton constructor

Private Methods

Method Description
fireWildcardEvents ( $eventName, $data, $resultType ) : null | array Process events starting with given prefix (ex: webiny.* will process all events starting with 'webiny.')

Method Details

disable() public method

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

enable() public method

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

fire() public method

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
return array Array of results from EventListeners

getEventListeners() public method

Get array of event listeners
public getEventListeners ( $eventName ) : array
$eventName
return array

init() protected method

Singleton constructor
protected init ( )

listen() public method

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
return EventListener Return instance of EventListener

subscribe() public method

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