Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Manager Class Reference
Inheritance diagram for Manager:
ManagerInterface Event\ManagerStub

Public Member Functions

 __construct (InvokerInterface $invoker, ConfigInterface $eventConfig)
 
 dispatch ($eventName, array $data=[])
 

Protected Attributes

 $_events = []
 
 $_invoker
 
 $_eventConfig
 

Detailed Description

Definition at line 11 of file Manager.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( InvokerInterface  $invoker,
ConfigInterface  $eventConfig 
)
Parameters
InvokerInterface$invoker
ConfigInterface$eventConfig

Definition at line 38 of file Manager.php.

39  {
40  $this->_invoker = $invoker;
41  $this->_eventConfig = $eventConfig;
42  }

Member Function Documentation

◆ dispatch()

dispatch (   $eventName,
array  $data = [] 
)

Dispatch event

Calls all observer callbacks registered for this event and multiple observers matching event name pattern

Parameters
string$eventName
array$data
Returns
void

Implements ManagerInterface.

Definition at line 54 of file Manager.php.

55  {
56  $eventName = mb_strtolower($eventName);
57  \Magento\Framework\Profiler::start('EVENT:' . $eventName, ['group' => 'EVENT', 'name' => $eventName]);
58  foreach ($this->_eventConfig->getObservers($eventName) as $observerConfig) {
59  $event = new \Magento\Framework\Event($data);
60  $event->setName($eventName);
61 
62  $wrapper = new Observer();
63  $wrapper->setData(array_merge(['event' => $event], $data));
64 
65  \Magento\Framework\Profiler::start('OBSERVER:' . $observerConfig['name']);
66  $this->_invoker->dispatch($observerConfig, $wrapper);
67  \Magento\Framework\Profiler::stop('OBSERVER:' . $observerConfig['name']);
68  }
69  \Magento\Framework\Profiler::stop('EVENT:' . $eventName);
70  }

Field Documentation

◆ $_eventConfig

$_eventConfig
protected

Definition at line 32 of file Manager.php.

◆ $_events

$_events = []
protected

Definition at line 18 of file Manager.php.

◆ $_invoker

$_invoker
protected

Definition at line 25 of file Manager.php.


The documentation for this class was generated from the following file: