Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InvokerDefault.php
Go to the documentation of this file.
1 <?php
10 
12 
13 class InvokerDefault implements \Magento\Framework\Event\InvokerInterface
14 {
20  protected $_observerFactory;
21 
27  protected $_appState;
28 
33  public function __construct(
34  \Magento\Framework\Event\ObserverFactory $observerFactory,
35  \Magento\Framework\App\State $appState
36  ) {
37  $this->_observerFactory = $observerFactory;
38  $this->_appState = $appState;
39  }
40 
48  public function dispatch(array $configuration, Observer $observer)
49  {
51  if (isset($configuration['disabled']) && true === $configuration['disabled']) {
52  return;
53  }
54 
55  if (isset($configuration['shared']) && false === $configuration['shared']) {
56  $object = $this->_observerFactory->create($configuration['instance']);
57  } else {
58  $object = $this->_observerFactory->get($configuration['instance']);
59  }
60  $this->_callObserverMethod($object, $observer);
61  }
62 
69  protected function _callObserverMethod($object, $observer)
70  {
71  if ($object instanceof \Magento\Framework\Event\ObserverInterface) {
72  $object->execute($observer);
73  } elseif ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
74  throw new \LogicException(
75  sprintf(
76  'Observer "%s" must implement interface "%s"',
77  get_class($object),
78  \Magento\Framework\Event\ObserverInterface::class
79  )
80  );
81  }
82  return $this;
83  }
84 }
__construct(\Magento\Framework\Event\ObserverFactory $observerFactory, \Magento\Framework\App\State $appState)
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$configuration
Definition: index.php:33
dispatch(array $configuration, Observer $observer)