Emits a message through the engine

@param string $event
@param array  $args

@return $this
483714
public function emit($event, array $args)
    {
        $this->logger->debug('Sending a new message', ['event' => $event, 'args' => $args]);
        $this->engine->emit($event, $args);

        return $this;
    }
707112
public function addEvent($event, array $params = []): self
    {
        $event = $this->wrapperEvent($event, null, $params);

        /** @var $event Event */
        if (($event instanceof EventInterface) && !isset($this->events[$event->getName()])) {
            $this->events[$event->getName()] = $event;
        }

        return $this;
    }
82128
public function triggerEvent($event, $args = [])
    {
        /** @var \Windwalker\Event\Dispatcher $dispatcher */
        $dispatcher = $this->container->get('dispatcher');

        $dispatcher->triggerEvent($event, $args);

        return $event;
    }
879924
function onQuickFormEvent($event, $arg, &$caller)
    {
        switch ($event) {
            case 'createElement':
                $choices=array();
                $choices[0] = get_string('no');
                $choices[1] = get_string('yes');
                $this->load($choices);
                break;
        }
        return parent::onQuickFormEvent($event, $arg, $caller);
    }
69932
public function trigger($events, $args = [])
    {
        $args[] = $this;
        if (!is_array($events)) {
            $events = [$events];
        }

        foreach ($events as $event) {
            dispatcher()->trigger(static::class . '.' . $event, $args);
            dispatcher()->trigger(Record::class . '.' . $event, $args);
        }

        return $this;
    }
909819
public static function fireEvent($event, $args = array(), $resultAsString = false)
    {
        $results = array();
        
        if (isset(self::$events[$event])) {
            $keys = array_keys(self::$events[$event]); 
            sort($keys);
            foreach ($keys as $key) {
                $callback = self::$events[$event][$key];
                $results[$key] = call_user_func_array($callback, $args);
            }
        }
        
        if ($resultAsString) {
            return implode('', $results);
        }
        return $results;
    }
1228286
public function fireDecoyEvent($event, $args = null)
    {
        $event = "decoy::model.{$event}: ".get_class($this);

        return Event::fire($event, $args);
    }
1234349
public static function runOne($events, $args)
    {
        foreach ($events as $key => $value) {
            $name = '\Vinala\App\Events\\'.$key;

            $object = new $name();

            $function = self::$listners[$key.'.'.$value];

            call_user_func_array([$object, $function], $args);
        }

        return true;
    }
140087
protected function dispatchEventToEventHandler($event, $arguments)
    {
        if ($this->eventHandler == null || ! method_exists($this->eventHandler, $method = "on{$event}")) {
            return;
        }

        try {
            $this->eventHandler->$method(...$arguments);
        } catch (Exception $e) {
            $this->handleException($e);
        } catch (Throwable $e) {
            $this->handleException(new FatalThrowableError($e));
        }
    }
223689
public function fire($event, $args)
    {
        $onEvent = $this->getConfig('events.'.$event);

        if ($onEvent instanceof Closure) {
            $onEvent($args);
        }
    }
721736
public EventBus emitSync(EventObject event, Object... args) {
        return _emitWithOnceBus(eventContextSync(event, args));
    }
253711
public function trigger(string $event, ...$args): EventInterface
    {
        $matches = $this->match($event);

        //if there are no events found
        if (empty($matches)) {
            //report a 404
            $this->meta = self::STATUS_NOT_FOUND;
            return $this;
        }

        $observers = [];
        foreach ($matches as $match) {
            $event = $match['pattern'];

            //if no direct observers
            if (!isset($this->observers[$event])) {
                continue;
            }

            //add args on to match
            $match['args'] = $args;

            //then loop the observers
            foreach ($this->observers[$event] as $observer) {
                //get the callback
                $callback = $observer['observer']->getCallback();
                $priority = $observer['priority'];
                //add on to match
                $match['callback'] = $callback;
                $observers[$priority][] = $match;
            }
        }

        //then sort by priority
        krsort($observers);
        if (!empty($observers)) {
            $observers = call_user_func_array('array_merge', $observers);
        }

        //call the callbacks
        foreach ($observers as $match) {
            //set the current
            $this->meta = $match;

            //if this is the same event, call the method, if the method returns false
            if (call_user_func_array($match['callback'], $args) === false) {
                //report a 308
                $this->meta = self::STATUS_INCOMPLETE;
                return $this;
            }
        }

        //report a 200
        $this->meta = self::STATUS_OK;

        return $this;
    }
180203
public function trigger($event = null)
    {
        //argument 1 must be string
        Argument::i()->test(1, 'string', 'null');

        call_user_func_array(
            array(Event::i(), 'trigger'),
            func_get_args()
        );

        return $this;
    }
393573
function onQuickFormEvent($event, $arg, &$caller)
    {
        switch ($event) {
            case 'createElement':
                $caller->setType($arg[0], PARAM_TAGLIST);
                break;
        }
        return parent::onQuickFormEvent($event, $arg, $caller);
    }
1310723
private function fireEvent($event)
    {
        $env = $this->formatEventName($event);

        if (emitter()->bound($env)) {
            emitter()->emit($env, $this);
        }
    }
1183506
public EventBus emitAsync(EventObject event, Object... args) {
        return _emitWithOnceBus(eventContextAsync(event, args));
    }
736193
public function trigger($event, $target = null, $argv = [])
    {
        if (!$event instanceof Event) {
            $event = new Event($event, $target, $argv);
        } else {
            $event->setTarget($target);
            $event->setParams($argv);
        }

        $allListeners = [];
        if (isset($this->listeners[$event->getName()])) {
            ksort($this->listeners[$event->getName()]);
            $allListeners = array_values($this->listeners[$event->getName()]);
        }

        $result = null;
        foreach ($allListeners as $listeners) {
            foreach ($listeners as $listener) {
                $result = call_user_func($listener, $event);
                if ($event->isPropagationStopped()) {
                    break 2;
                }
            }
        }

        return $result;
    }