Zend\Mvc\Controller\ControllerManager::injectEventManager PHP Метод

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

If we have an event manager composed already, make sure it gets injected with the shared event manager. The AbstractController lazy-instantiates an EM instance, which is why the shared EM injection needs to happen; the conditional will always pass.
public injectEventManager ( Interop\Container\ContainerInterface | Zend\Stdlib\DispatchableInterface $first, Zend\Stdlib\DispatchableInterface | Interop\Container\ContainerInterface $second )
$first Interop\Container\ContainerInterface | Zend\Stdlib\DispatchableInterface Container when using zend-servicemanager v3; controller under v2.
$second Zend\Stdlib\DispatchableInterface | Interop\Container\ContainerInterface Controller when using zend-servicemanager v3; container under v2.
    public function injectEventManager($first, $second)
    {
        if ($first instanceof ContainerInterface) {
            $container = $first;
            $controller = $second;
        } else {
            $container = $second;
            $controller = $first;
        }
        if (!$controller instanceof EventManagerAwareInterface) {
            return;
        }
        $events = $controller->getEventManager();
        if (!$events || !$events->getSharedManager() instanceof SharedEventManagerInterface) {
            // For v2, we need to pull the parent service locator
            if (!method_exists($container, 'configure')) {
                $container = $container->getServiceLocator() ?: $container;
            }
            $controller->setEventManager($container->get('EventManager'));
        }
    }