Get/set the application's event manager.

If the application does not support events and this method is used as
a setter, an exception will be raised.

@param \Cake\Event\EventManager $events The event manager to set.
@return $this
174083
public function setEventManager(EventManager $events)
    {
        if ($this->app instanceof PluginApplicationInterface) {
            $this->app->setEventManager($events);

            return $this;
        }

        throw new InvalidArgumentException('Cannot set the event manager, the application does not support events.');
    }
1361756
public function onEventRegistration(Event $event)
    {
        $this->unitOfWork->publishEvent($event, $this->eventBus);

        return $this->unitOfWork->invokeEventRegistrationListeners($event);
    }
285247
public function persist(array $events)
    {
        $factory = new EventFactory();
        $events = array_map(
            function ($event) use ($factory) {
                return is_array($event) ? $factory->create($event) : $event;
            },
            $events
        );
        $this->persister()->logEvents($events);
    }
606136
public function getEventManager()
    {
        if ($this->eventManager === null) {
            $this->eventManager = \FreeFW\Listener\EventManager::getInstance();
        }
        return $this->eventManager;
    }
1266634
function bind(iEvent $event)
    {
        $eventName = $event->getName();
        if ($this->has($event))
            throw new \Exception(sprintf(
                'Events with name "%s" is registered before.'
                , $eventName
            ));


        if ($this->meeter !== null)
            $event->setMeeter($this->meeter);

        $this->attached_events[$eventName] = $event;
        return $this;
    }
957419
public function setEvents($events)
    {
        foreach ($events as $key => $dtoData) {
            $this->events[$key] = new MatchEventDto($dtoData);
        }
    
        return $this;
    }
654069
public static function getEventManager()
    {
        if (!isset(self::$event_manager[get_called_class()])) {
            self::$event_manager[get_called_class()] =
                EventDispatcher::getShareable(static::$static_scope);
        }
        return self::$event_manager[get_called_class()];
    }
113083
public function setEventManager(EventManagerInterface $events)
    {
        $events->setIdentifiers(array(
            __CLASS__,
            get_class($this)
        ));
        $events->setSharedManager(
            $this->getContainer()->get("sharedEventManager")
        );
        $this->_events = $events;
        return $this;
    }
345458
public function addAllowedEvents(array $eventNames): self
    {
        foreach ($eventNames as $eventName) {
            $this->addAllowedEvent($eventName);
        }

        return $this;
    }
1172007
public function setEventManager(EventManagerInterface $events)
    {
        $identifiers = array('Social');
        $events->setIdentifiers($identifiers);
        $this->eventManager = $events;

        return $this;
    }
748675
public function setEvents($value)
    {
        if (empty($value)) {
            $value = $this->events_list;
        } elseif (!is_array($value)) {
            $value = [$value];
        }

        $this->values['events'] = $value;

        return $this;
    }
1246630
public function createSuccessFromEventCollection(
        EventCollection $events
    ): EventCollection {
        $suiteClass = $this->suiteClass;
        $suiteClass::current()->assert($this->successConfig);

        return $events;
    }
167045
public function events($events=array())
    {
        if (!isset($this->_events)) {
            $this->_events = new Events(array(), self::schema()->events());
            $this->_registerDefaultEventHandlers();
        }

        if(count($events))
            foreach($events as $event=>$callback)
                $this->_events->register($event, $callback);

        return $this->_events;
    }
1139123
public function triggerEvent($event)
	{
		if (!($event instanceof EventInterface))
		{
			if (isset($this->events[$event]))
			{
				$event = $this->events[$event];
			}

			else
			{
				$event = new Event($event);
			}
		}

		if (isset($this->listeners[$event->getName()]))
		{
			foreach ($this->listeners[$event->getName()] as $listener)
			{
				if ($event->isStopped())
				{
					return $event;
				}

				if ($listener instanceof Closure)
				{
					call_user_func($listener, $event);
				}

				else
				{
					call_user_func(array($listener, $event->getName()), $event);
				}
			}
		}

		return $event;
	}
497672
public function getEventManager()
    {
        if (!$this->eventManager instanceof EventManagerInterface) {
            $this->setEventManager(new EventManager(array(__CLASS__, get_called_class())));
        }
        return $this->eventManager;
    }
1313991
public function doesntExpectEvents($events)
    {
        $events = is_array($events) ? $events : func_get_args();

        $this->withoutEvents();

        $this->beforeApplicationDestroyed(function () use ($events) {
            $this->assertEmpty(
                $fired = $this->getFiredEvents($events),
                'These unexpected events were fired: ['.implode(', ', $fired).']'
            );
        });

        return $this;
    }
1336174
public function getEventManager()
    {
        if (is_null($this->_events)) {
            $container = ContainerBuilder::buildContainer(
                [
                    'DefaultEventManager' => Definition::object(
                            'Zend\EventManager\SharedEventManager'
                    )
                ]
            );
            $sharedEvents = $container->get('DefaultEventManager');
            $events = new EventManager();
            $events->setSharedManager($sharedEvents);
            $this->setEventManager($events);
        }
        return $this->_events;
    }