Inject an EventManager instance.

@param \Zend\EventManager\EventManagerInterface $eventManager
426798
public function setEventManager(\Zend\EventManager\EventManagerInterface $events)
    {
        $this->events = $events;
        $this->events->setIdentifiers([__CLASS__,get_called_class()]);
        
        return $this;
    }
571100
public function subscribe(EventManager $eventManager)
    {
        $eventManager->attach(self::EVENT_BEFORE_WEB_METHOD, [$this, 'beforeWebMethod'])
            ->attach(self::EVENT_AFTER_WEB_METHOD, [$this, 'afterWebMethod'])
            ->attach(self::EVENT_BEFORE_CLI_METHOD, [$this, 'beforeCLiMethod'])
            ->attach(self::EVENT_AFTER_CLI_METHOD, [$this, 'afterCLiMethod']);
    }
626661
public function eventManager(EventManager $eventManager = null)
    {
        if ($eventManager !== null) {
            $this->_eventManager = $eventManager;
        }

        return $this->_eventManager;
    }
272754
public function injectEventManager($assertion, $serviceLocator)
    {
    	//@TODO: [ZF3] check if ACL working properly
        /* @var $serviceLocator AssertionManager */

        if (!$assertion instanceof EventManagerAwareInterface) {
            return;
        }
        /* @var EventManager $events */
	    $container = $this->container;
        $events = $assertion->getEventManager();
        if (!$events instanceof EventManagerInterface) {
            $events = $container->get('EventManager'); /* @var $events \Zend\EventManager\EventManagerInterface */
            $assertion->setEventManager($events);
        } else {
        	//@TODO: [ZF3] setSharedManager method now is removed
            //$sharedEvents = $container->get('SharedEventManager'); /* @var $sharedEvents \Zend\EventManager\SharedEventManagerInterface */
            //$events->setSharedManager($sharedEvents);
        }
    }
400732
public function createService(ServiceLocatorInterface $controllerManager)
    {
        /* @var ControllerManager $controllerManager*/
        $serviceManager = $controllerManager->getServiceLocator();

        return $this->__invoke($serviceManager, null);
    }
891134
public function attach(EventManagerInterface $events)
    {
        foreach ($this->eventMap as $eventName => $items) {
            if (!is_array($items)) {
                $errMsg = 'Handlers config not array';
                throw new Exception\RuntimeException($errMsg);
            }

            foreach ($items as $item) {
                if (!is_array($item)) {
                    $errMsg = 'Handler not array';
                    throw new Exception\RuntimeException($errMsg);
                }

                if (!array_key_exists('handler', $item)) {
                    $errMsg = 'Handler not found';
                    throw new Exception\RuntimeException($errMsg);
                }
                $handler = $item['handler'];

                $priority = 1;
                if (array_key_exists('priority', $item)) {
                    $priority = (integer)$priority;
                }

                $this->listeners[] = $events->attach($eventName, $handler, $priority);
            }
        }
    }
1265030
public function injectEntityManager(EntityManagerInterface $entityManager, ClassMetadata $classMetadata) : void
    {
        if ($entityManager !== self::$entityManager) {
            throw new RuntimeException(
                'Trying to use PersistentObject with different EntityManager instances. ' .
                'Was PersistentObject::setEntityManager() called?'
            );
        }

        $this->cm = $classMetadata;
    }
831703
public function injectObjectManager(ObjectManagerInterface $objectManager): void
    {
        if ($this->objectManager === null) {
            $this->objectManager = $objectManager;
            /** @var CacheManager $cacheManager */
            $cacheManager = $this->objectManager->get(CacheManager::class);
            $this->runtimeExpressionsCache = $cacheManager->getCache('Flow_Aop_RuntimeExpressions');
        }
    }
802251
public function getEventManager()/*# : EventManagerInterface */
    {
        // create the default slave
        if (is_null($this->event_manager)) {
            // add own classname as scope
            $this->setEventManager(new EventDispatcher(get_class($this)));
        }

        // attach self to the event manager if not yet
        $this->attachSelfToEventManager();

        return $this->event_manager;
    }
1291406
public function addEventSubscriber(EventSubscriberInterface $subscriber)
    {
        if (!$this->dispatcher) {
            $this->dispatcher = new EventDispatcher();
        }

        $this->dispatcher->addSubscriber($subscriber);

        return $this;
    }
1234527
public function init(ModuleManagerInterface $manager)
    {
        $serviceManager = $manager->getEvent()->getParam('ServiceManager');
        if ($serviceManager->get(Environment::class)->is(self::ENVIRONMENT_CLI)) {
            $manager->getEventManager()->attach(
                ModuleEvent::EVENT_LOAD_MODULES_POST,
                [$this, 'addCliConfig'],
                PHP_INT_MAX
            );
        }
        $manager->getEventManager()->attach(ModuleEvent::EVENT_MERGE_CONFIG, [$this, 'onMergeConfig']);
    }
166160
protected function attachSelfToEventManager()
    {
        if (!$this->listener_attached) {
            if ($this->event_manager instanceof ListenerAwareInterface &&
                $this instanceof ListenerInterface
            ) {
                $this->event_manager->attachListener($this);
            }
            $this->listener_attached = true;
        }
    }
1023340
public function attach(EventManagerInterface $events)
    {
        $events->attach(
            MvcEvent::EVENT_RENDER,
            function (MvcEvent $event) {
                /** @var ServiceManager $serviceManager */
                $serviceManager = $event->getTarget()->getServiceManager();
                /** @var ControllerManager $controllerManager */
                $controllerManager = $serviceManager->get('ControllerManager');
                $routeMatch = $event->getRouteMatch();
                if ($routeMatch) {
                    $controller = $controllerManager->get($routeMatch->getParam('controller'));
                    $viewHelperManager = $serviceManager->get('ViewHelperManager');
                    /** @var Widget $widgetViewHelper */
                    $widgetViewHelper = $viewHelperManager->get('widget');
                    $widgetViewHelper->setController($controller);
                }
            },
            $this->priority
        );
    }
115106
public function setEventManager(EventManagerInterface $events)
    {
        $events->setIdentifiers(array(
            __CLASS__,
            get_class($this),
        ));
        $events->attach(new OperationAnnotationsListener());
        $events->attach(new ServiceAnnotationsListener());
        $this->events = $events;
        return $this;
    }
644533
public function getEventsManager() {
    if (!is_object(parent::getEventsManager())) {
      $em = $this->getUserOption('eventsManager');
      if (!is_object($em)) {
        $em = new EventsManager();
      }
      $em->enablePriorities(true);
      $this->setEventsManager($em);
    }
    return parent::getEventsManager();
  }
1044237
public function injectActionHandles(EventInterface $event)
    {
        $handles = $this->getActionHandles($event);
        foreach ($handles as $handle) {
            $this->updater->addHandle($handle);
        }
    }
991134
function getEventManager()
    {
        if ($this->eventManager)
            return $this->eventManager;

        $eventManager = $this->getServiceManager()
            ->get('EventManager')
                ->setIdentifiers(array(
                    __CLASS__,
                    get_class($this),
                    // Default Identifier
                    'Zend\Mvc\Application',
                ));

        $this->eventManager = $eventManager;

        return $this->eventManager;
    }