Dispatch a daemon event.

@param string $eventName
@return DaemonCommand
427422
protected function dispatchEvent(string $eventName): self
    {
        $dispatcher = $this->getEventDispatcher();
        if (!is_null($dispatcher)) {
            $time = !is_null($this->startTime) ? microtime(true) - $this->startTime : 0;

            $event = new DaemonEvent($this);
            $event->setExecutionTime($time);

            $dispatcher->dispatch($eventName, $event);
        }

        return $this;
    }
57451
public function getNotificationEvent($eventName)
    {
        // normalise the event name
        $eventName = strtr($eventName, '_', '-');
        if ($this->hasNotificationEvent($eventName)) {
            return $this->events[$eventName];
        } else {
            throw new \InvalidArgumentException('Event '.$eventName.' is not registered');
        }
    }
972868
public function queue($eventName, $payload = array())
    {
        $me = $this;

        $this->subscribe($eventName . self::QUEUE_NAME, function () use ($me, $eventName, $payload) {
            return $me->dispatch($eventName, $payload);
        });
    }
831701
private function sortListeners(string $eventName)
	{
        $listeners = &$this->listeners[$eventName];

		\krsort($listeners);
		$this->sorted[$eventName] = \array_merge(...$listeners);
	}
739502
public function dispatch($eventName = null)
    {
        // Tries to fetch the event by the given eventname
        $event = null;
        if (null !== $eventName) {
            $event = $this->fetchEvent($eventName);
        }

        // Fetches the last saved event
        if (null === $event && !empty($this->events)) {
            $eventNames = array_keys($this->events);
            $events = array_values($this->events);
            $elemens = count($events) - 1;
            $event = $events[$elemens];
            $eventName = $eventNames[$elemens];
        }

        if (null === $event) {
            throw new RuntimeException('exception_no_events');
        }

        $this->eventDispatcher->dispatch($eventName, $event);

        return $this;
    }
1113660
public function invokeGlobalEvent($eventName, EventArgs $event)
    {
        if ($this->eventManager->hasListeners($eventName)) {
            $this->eventManager->dispatchEvent($eventName, $event);
        }
    }
1368299
protected function dispatch($eventName, Event $event = null)
    {
        if ($event == null) {
            $event = new DefaultActionEvent();
        }

        $this->getDispatcher()->dispatch($eventName, $event);
    }
1357886
protected function lazyLoad($eventName)
    {
        if (isset($this->listenerIds[$eventName])) {
            foreach ($this->listenerIds[$eventName] as $args) {
                list($serviceId, $method, $priority) = $args;
                $listener = $this->container->get($serviceId);

                $key = $serviceId.'.'.$method;
                if (!isset($this->listeners[$eventName][$key])) {
                    $this->addListener($eventName, array($listener, $method), $priority);
                } elseif ($listener !== $this->listeners[$eventName][$key]) {
                    parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method));
                    $this->addListener($eventName, array($listener, $method), $priority);
                }

                $this->listeners[$eventName][$key] = $listener;
            }
        }
    }
415008
public function dispatch($eventName, Event $event)
    {
        if (!$this->hasListeners($eventName)) {
            return $event;
        }

        // setting event name
        $event->setName($eventName);

        // execute all callbacks for a event given
        foreach ($this->getListeners($event->getName()) as $listener) {
            call_user_func($listener, $event);

            if ($event->isPropagationStopped()) {
                break;
            }
        }

        return $event;
    }
651591
protected function offAll(string $eventName): self
    {
        $hasEvent = $this->listeners[$eventName] ?? false;
        if ($hasEvent) {
            unset($this->listeners[$eventName], $this->sorted[$eventName]);
        }

        return $this;
    }
435456
private function sortListeners(string $eventName)
    {
        krsort($this->listeners[$eventName]);
        $this->sorted[$eventName] = [];

        foreach ($this->listeners[$eventName] as &$listeners) {
            foreach ($listeners as $k => $listener) {
                if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
                    $listener[0] = $listener[0]();
                }
                $this->sorted[$eventName][] = $listener;
            }
        }
    }
433466
protected function _triggerEvent($eventName, $entity, $eventArgs)
    {
        if (null === $this->_application) {
            return;
        }

        $dispatcher = $this->_application->getEventDispatcher();
        if (null !== $dispatcher) {
            $dispatcher->triggerEvent($eventName, $entity, $eventArgs);
        }
    }
1082186
public function flush($eventName)
    {
        $result = $this->dispatch($eventName . self::QUEUE_NAME);
        // If result is an array then need to merge or will end up with array of arrays.
        if (is_array($result)) {
            $result = call_user_func_array('array_merge', $result);
        }

        return $result;
    }
663359
public function removeEventListener($eventName, $listener)
    {
        if (!$this->dispatcher) {
            $this->dispatcher = new EventDispatcher();
        }

        $this->dispatcher->removeListener($eventName, $listener);

        return $this;
    }
942644
public function notify($eventName, array $params = array())
    {
        $this->dispatcher->notify($e = $this->createEvent($eventName, $params));
        return $e;
    }
712069
private function getSortedRegistry($eventName) {
		
		if(!isset($this->sortedRegistry[$eventName])) {
			
			$this->sortedRegistry[$eventName] = [];
			
			if (isset($this->registry[$eventName])) {
				
				// sort reverse by priority key

				krsort($this->registry[$eventName]);
				
				// merge the sorted arrays into one

				$this->sortedRegistry[$eventName] = call_user_func_array('array_merge', $this->registry[$eventName]);
			}
		}

		return $this->sortedRegistry[$eventName];

	}
915361
public function dispatch($event/*, string $eventName = null*/)
    {
        $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null;

        if (\is_object($event)) {
            $eventName = $eventName ?? \get_class($event);
        } else {
            @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), E_USER_DEPRECATED);
            $swap = $event;
            $event = $eventName ?? new Event();
            $eventName = $swap;

            if (!$event instanceof Event) {
                throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an instance of %s, %s given.', EventDispatcherInterface::class, Event::class, \is_object($event) ? \get_class($event) : \gettype($event)));
            }
        }

        $listeners = $this->getListeners($eventName);
        $stoppable = $event instanceof Event || $event instanceof ContractsEvent || $event instanceof StoppableEventInterface;

        foreach ($listeners as $listener) {
            if ($stoppable && $event->isPropagationStopped()) {
                break;
            }
            $listener($event, $eventName, $this);
        }

        return $event;
    }