Fires event.

@param  string     $name       Event name
@param  I_Registry $args       Event arguments
@param  bool       $fireAgain  Allow to fire event again
@return void
@throws RuntimeException  When invalid handler passed or event already fired.
963557
public function fire($name, I_Registry $args, $fireAgain = false)
    {
        $uid = uniqid('');
        if ($this->debug && !in_array($name, self::$debugEvents)) {
            $debugArgs = new Args([
                'uid'    => $uid,
                'name'   => $name,
                'args'   => $args,
                'source' => 'core:event:debug',
                'level'  => E_NOTICE,
            ]);
            $this->fire(':onEventStart:', $debugArgs);
            unset($debugArgs);
        }
        if (isset($this->handlers[$name]) && empty($this->disabledEvents[$name])) {
            if (!$fireAgain && isset($this->firedEvents[$name])) {
                throw new RuntimeException(
                    sprintf(
                        "Event '%s' is fired already",
                        $name
                    )
                );
            } else {
                $this->firedEvents[$name] = true;
                if (!isset($this->orderedHandlers[$name])) {
                    $this->orderedHandlers[$name] = $this->handlers[$name];
                    $this->sortEvents($name);
                }
                foreach (array_keys($this->orderedHandlers[$name]) as $index) {
                    if (empty($this->orderedHandlers[$name][$index][1])) {
                        // Targeted event, not for this target
                        continue;
                    }
                    // Call handler
                    $callback = $this->orderedHandlers[$name][$index][1];
                    if (!is_callable($callback)) {
                        unset($this->firedEvents[$name]);
                        if (is_array($callback)) {
                            $callback =
                                (
                                    is_object($callback[0])
                                        ? get_class($callback[0]) . '->'
                                        : $callback[0] . '::'
                                ) .
                                $callback[1];
                        } else {
                            $callback = sprintf("function %s", $callback);
                        }

                        throw new RuntimeException(
                            sprintf(
                                "Invalid event handler %s() added to process '%s' event",
                                $callback,
                                $name
                            )
                        );
                    }

                    if ($this->debug && !in_array($name, self::$debugEvents)) {
                        $debugArgs = new Args([
                            'uid'     => $uid,
                            'name'    => $name,
                            'handler' => $this->orderedHandlers[$name][$index][1],
                            'args'    => $args,
                            'source'  => 'core:event:debug',
                            'level'   => E_NOTICE,
                        ]);
                        $this->fire(':onHandlerFound:', $debugArgs);
                    }
                    call_user_func(
                        $this->orderedHandlers[$name][$index][1],
                        $name,
                        $args
                    );
                    if (!$args->isEmpty(':break:')) {
                        break;
                    }
                }
                unset($this->firedEvents[$name]);
            }
        }
        if ($this->debug && !in_array($name, self::$debugEvents)) {
            $debugArgs = new Args([
                'uid'    => $uid,
                'name'   => $name,
                'args'   => $args,
                'source' => 'core:event:debug',
                'level'  => $args->get(':break:', false) ? E_WARNING : E_NOTICE,
            ]);
            $this->fire(':onEventEnd:', $debugArgs);
        }
    }
312807
public function dispatchEvent(DispatcherInterface $dispatcher, $name, \ArrayAccess $context = null)
    {
        if ($this->dispatcher) {
            throw new \RuntimeException('Event dispatching is still running!');
        } else {
            if ($this->currentState->hasEvent($name)) {
                $this->acquireLockOrThrowException();
                $this->dispatcher = $dispatcher;

                if ($context) {
                    $this->currentContext = $context;
                } else {
                    $this->currentContext = new \ArrayIterator(array());
                }
                $this->currentEvent = $this->currentState->getEvent($name);

                $dispatcher->dispatch($this->currentEvent, array($this->subject, $this->currentContext), new Callback(array($this, 'onDispatcherReady')));
            } else {
                throw new WrongEventForStateException($this->currentState->getName(), $name);
            }
        }
    }
1017001
public function trigger($event, $target = null, $argv = array()){
        if(!($event instanceof EventInterface)){
            $event = new Event($event, $target, $argv);
        }
        if(isset($this->listeners[$event->getName()])){
            $this->listeners[$event->getName()]->perform($event);
        }
    }
1275011
public function emit(string $name, array $arguments = [])
    {
        try {
            $this->trigger($name, $arguments);
        } catch (StopPropagation $e) {
            return $this;
        }

        return $this;
    }
1115036
public static function trigger($name, array $args = array())
    {
        if ($name === 'error') {
            self::$state = 5;
        }

        if (empty(self::$events[$name])) {
            return null;
        }

        $listen = self::$events[$name];

        usort($listen, function ($a, $b) {
            return $b[1] >= $a[1];
        });

        foreach ($listen as $callback) {
            call_user_func_array($callback[0], $args);
        }

        $listen = null;
    }
391213
protected function trigger(string $name, array $arguments = [], $value = null)
    {
        $event = $this->listeners[$name] ?? false;
        if ($event) {
            $this->sortListeners($name);
            foreach ($this->listeners[$name] as $handlers) {
                foreach ($handlers as $paramsHandler) {
                    $callArgs = $this->getCallArgs($arguments, $paramsHandler['extraArguments'], $value);
                    $value = $paramsHandler['handler'](...$callArgs);
                    $this->offOnce($paramsHandler, $name);
                }
            }
        }

        return $value;
    }
964412
def fire_event(self, name, exc=None, data=None):
        
        if self._events and name in self._events:
            self._events[name].fire(exc=exc, data=data)
1002317
protected function fireFinalEvent($name = null, $resource = null)
    {
        if (empty($name)) {
            $name = $this->getEventName();
        }
        if (empty($resource)) {
            $resource = $this->getEventResource();
        }
        /** @noinspection PhpUnusedLocalVariableInspection */
        $results = \Event::fire(new ApiEvent($name, $this->request, $this->response, $resource));
    }
361629
public function fire(string $event, array $arguments = null) {
        return $this->getEventManager()->fire($event, $arguments);
    }
320982
public function triggerEvent($event, $args = [])
    {
        if (!is_string($event) && !$event instanceof Event) {
            throw new \InvalidArgumentException(sprintf(
                '%s::%s only allow Event object or string.',
                get_called_class(),
                __FUNCTION__
            ));
        }

        if (!($event instanceof Event)) {
            if (isset($this->events[$event])) {
                $event = $this->events[$event];
            } else {
                $event = new Event($event);
            }
        }

        $event->mergeArguments($args);

        $listeners = [];

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

                if (!is_callable($listener)) {
                    $listener = [$listener, $event->getName()];
                }

                if (!is_callable($listener)) {
                    continue;
                }

                $listener($event);

                if ($this->debug) {
                    $listeners[] = $listener;
                }
            }
        }

        if ($this->debug) {
            $executedListeners = [];

            foreach ($listeners as $listener) {
                if ($listener instanceof \Closure) {
                    $ref = new \ReflectionFunction($listener);

                    $listener = ['{Closure}: ' . $ref->getFileName() . ' - Line: ' . $ref->getStartLine()];
                }

                if (is_object($listener[0])) {
                    $listener[0] = get_class($listener[0]);
                }

                $executedListeners[] = $listener;
            }

            $this->collector[] = [
                'event' => $event->getName(),
                'listeners' => $executedListeners,
            ];
        }

        return $event;
    }
85787
public function triggerEvent($event, $args = [])
    {
        if (!($event instanceof EventInterface)) {
            if (isset($this->events[$event])) {
                $event = $this->events[$event];
            } else {
                $event = new Event($event);
            }
        }

        $event->mergeArguments($args);

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

                if (is_callable($listener)) {
                    call_user_func($listener, $event);
                } else {
                    call_user_func([$listener, $event->getName()], $event);
                }
            }
        }

        return $event;
    }
1221830
public static function call($name, $arguments = []) {
		if (self::exists($name)) {
			$application = Application::get();
			$classname = 'Hook_' . ucfirst($application->name);
			call_user_func_array([$classname, $name], $arguments);
		} else {
			throw new \Exception('Hook is not defined');
		}
	}
282891
protected function handle($name, array $args = [])
    {
        if (isset($this->handlers[$name]) && is_callable($this->handlers[$name])) {
            array_unshift($args, $this);
            call_user_func_array($this->handlers[$name], $args);
        }
    }
693210
public function trigger($name, ...$args)
    {
        if ($this->addThisToEvents) {
            array_unshift($args, $this);
        }
        if (isset($this->eventHandlers[$name])) {
            $this->lastEventName = $name;
            foreach ($this->eventHandlers[$name] as $cb) {
                if ($cb(...$args) === true) {
                    return $this;
                }
            }
        }
        return $this;
    }
661899
public static function trigger(string $name, ?array $args = null)
  {
    if (!isset(self::$events[$name])) return false;

    foreach (self::$events[$name] as $event => $callback) {
      if (is_callable($callback)) {
        return call_user_func_array($callback, isset($args) ? $args : []);
      }
      else if (is_array($callback)) {
        (new Events)->triggerGroup($callback, $args);
      }
      else if (is_string($callback)) {
        $call = new $callback;
        return call_user_func_array([$call, 'persist'], $args ?? []);
      }
    }
  }
525541
private function fireCallbacks($name, Closure $modifier = null, Closure $caller = null)
    {
        $list = collect($this->{$name . 'Callbacks'});
        if ($modifier) {
            $list = call_user_func_array($modifier, [ $list ]);
        }
        $caller = $caller ?: function (Closure $callback) {
            $callback->bindTo($this);
            $callback($this->app);
        };
        $list->pluck('callback')->each($caller);
    }
1113660
public function invokeGlobalEvent($eventName, EventArgs $event)
    {
        if ($this->eventManager->hasListeners($eventName)) {
            $this->eventManager->dispatchEvent($eventName, $event);
        }
    }