Fire an event and call the listeners.

@param  string|object  $event
@param  mixed  $payload
@param  bool  $halt
@return array|null
772872
public function fire($event, &$payload = [], $halt = false)
    {
        // When the given "event" is actually an object we will assume it is an event
        // object and use the class as the event name and this event itself as the
        // payload to the handler, which makes object based events quite simple.
        if ( is_object($event) )
        {
            list($payload, $event, $eventName) = [ [$event], $event, get_class($event) ];
        }
        else
        {
            $eventName = $event;
        }

        $responses = [];

        // If an array is not given to us as the payload, we will turn it into one so
        // we can easily use call_user_func_array on the listeners, passing in the
        // payload to each of them so that they receive each of these arguments.
        if ( ! is_array($payload) )
        {
            $payload = [$payload];
        }

        $this->firing[] = $eventName;

        if ( isset($payload[0]) && $payload[0] instanceof ShouldBroadcast )
        {
            $this->broadcastEvent($payload[0]);
        }

        foreach ($this->getListeners($event) as $listener)
        {
            dd($listener());
        	
        	try
        	{
        		$response = call_user_func_array($listener, $payload);
        	}
            catch(ValidationException $e)
            {
            	$this->validationExceptions[] = $e;
            	$response = 0;
            }

            // If a response is returned from the listener and event halting is enabled
            // we will just return this response, and not call the rest of the event
            // listeners. Otherwise we will add the response on the response list.
            if (!is_null($response) && $halt)
            {
                array_pop($this->firing);

                return $response;
            }

            // If a boolean false is returned from a listener, we will stop propagating
            // the event to any further listeners down in the chain, else we keep on
            // looping through the listeners and firing every one in our sequence.
            if ($response === false)
            {
                break;
            }

            $responses[] = $response;
        }

        array_pop($this->firing);

        if( ! empty($this->validationExceptions) )
        {
        	throw new ValidationException([], 422, $this->validationExceptions);
        	
        }

        return $halt ? null : $responses;
    }
513503
public function trigger($event = null, &$payload = null)
    {
        // Disallow calling a trigger on global docks
        if ($event === '*') {
            return $this;
        }

        // Get all global docks
        $globalDocks = [];
        if (isset($this->docks['*']) && count($this->docks['*']) > 0) {
            $globalDocks = $this->docks['*'];
        }

        // Check if the event exists and has callables to run
        if (!isset($this->docks[$event]) || count($this->docks[$event]) === 0) {
            // There are no specific docks, but maybe there's global docks?
            if (count($globalDocks) === 0) {
                // There is nothing to do here
                return $this;
            }
            $docks = $globalDocks;
        } else {
            $docks = $this->docks[$event];
            $docks = array_merge($docks, $globalDocks);
        }

        // All good, let's call those callables
        foreach ($docks as $dock) {
            $dock['callable']($event, $payload);

            // And include the template if we have one. Data should be passed to the template through
            // outside means like through the session or \Parable\GetSet or one of its sub-types.
            if ($dock['templatePath'] && file_exists($dock['templatePath'])) {
                ob_start();
                require $dock['templatePath'];
                $return = ob_get_clean();
                echo $return;
            }
        }
        return $this;
    }
694486
public function recordEvent($eventName, $payload)
    {
        if (! Telescope::isRecording() || $this->shouldIgnore($eventName)) {
            return;
        }

        $formattedPayload = $this->extractPayload($eventName, $payload);

        Telescope::recordEvent(IncomingEntry::make([
            'name' => $eventName,
            'payload' => empty($formattedPayload) ? null : $formattedPayload,
            'listeners' => $this->formatListeners($eventName),
            'broadcast' => class_exists($eventName)
                        ? in_array(ShouldBroadcast::class, (array) class_implements($eventName))
                        : false,
        ])->tags(class_exists($eventName) && isset($payload[0]) ? ExtractTags::from($payload[0]) : []));
    }
473980
public function trigger($event, &$payload = null)
    {
        // Disallow calling a trigger on global hooks
        if ($event === '*') {
            return $this;
        }

        // Get all global hooks
        $globalHooks = [];
        if (isset($this->hooks['*']) && count($this->hooks['*']) > 0) {
            $globalHooks = $this->hooks['*'];
        }

        // Check if the event exists and has callables to run
        if (!isset($this->hooks[$event]) || count($this->hooks[$event]) === 0) {
            // There are no specific hooks, but maybe there's global hooks?
            if (count($globalHooks) === 0) {
                // There is nothing to do here
                return $this;
            }
            $hooks = $globalHooks;
        } else {
            $hooks = $this->hooks[$event];
            $hooks = array_merge($hooks, $globalHooks);
        }

        // All good, let's call those callables
        foreach ($hooks as $callable) {
            $callable($event, $payload);
        }
        return $this;
    }
83414
public function fire($event, $subject = null, $message = null)
    {
        $this->stop = false;

        try {
            foreach ([$event . ':before', $event, $event . ':after'] as $eventName) {
                if ($this->stop) {
                    break;
                }

                $subject = $this->call($eventName, $subject, $message);
            }

            return $subject;
        } catch (\Exception $e) {
            if (!isset($this->events[$event . ':exception'])) {
                throw $e;
            }

            return $this->call($event . ':exception', $e, $e->getMessage());
        }
    }
26103
public function queueEvent($event)
    {
        $this->queue->enqueue($event);

        $class = get_class($event);
        foreach ($this->synchronousEventMap->getListenersForEvent($class) as $listener)
        {
            $this->invokeListener($listener, $event);
        }
    }
181320
public function event($name, $payload = null) {
		$this->log->log("EVENT: $name",  Net_XMPP_XMPPHP_Log::LEVEL_DEBUG);
		foreach($this->eventhandlers as $handler) {
			if($name == $handler[0]) {
				if($handler[2] === null) {
					$handler[2] = $this;
				}
				$handler[2]->$handler[1]($payload);
			}
		}
		foreach($this->until as $key => $until) {
			if(is_array($until)) {
				if(in_array($name, $until)) {
					$this->until_payload[$key][] = array($name, $payload);
					if(!isset($this->until_count[$key])) {
						$this->until_count[$key] = 0;
					}
					$this->until_count[$key] += 1;
					#$this->until[$key] = false;
				}
			}
		}
	}
1263383
public function push($event, $payload = [])
    {
        $this->listen($event.'_pushed', function () use ($event, $payload) {
            $this->dispatch($event, $payload);
        });
    }
358250
public static function fire($event, $data = null)
    {
        if (!is_array($data)) {
            $data = array($data);
        }
        array_unshift($data, $event);

        $retval = true;

        foreach (array('*', $event) as $e) {
            if (!array_key_exists($e, self::$events)) {
                continue;
            }

            foreach (self::$events[$e] as $callback) {
                if (!is_callable($callback)) {
                    continue;
                }

                if (($retval = call_user_func_array($callback, $data)) === false) {
                    break 2;
                }
            }
        }

        return $retval !== false;
    }
1259415
public function execute($action, array $payload)
    {
        $executor = $this->getExecutor($action);

        // dispatch pre event, listeners may change the payload here
        $event = new ExecutionEvent($executor, $action, $payload);
        $this->dispatcher->dispatch(WorkerEvents::PRE_EXECUTE_ACTION, $event);

        try {
            $resolver = $this->getPayloadResolver($executor);
            $payload  = $resolver->resolve($event->getPayload());
        } catch (ExceptionInterface $exception) {
            $this->logger->error(
                sprintf(
                    'Payload %s for "%s" is invalid: %s',
                    json_encode($payload, JSON_UNESCAPED_SLASHES),
                    $action,
                    $exception->getMessage()
                )
            );

            return false;
        }

        $result = $executor->execute($payload);
        // dispatch post event, listeners may change the result here
        $event->setResult($result);
        $this->dispatcher->dispatch(WorkerEvents::POST_EXECUTE_ACTION, $event);

        return $event->getResult();
    }
1136768
public function trigger( $trigger, $params = [], $halt = false )
	{
		$keys = explode( '.', $trigger );
		$current = $this->triggers;
		$results = [];

		foreach ( $keys as $key )
		{
			$current = Arr::get( $current, $key );
			if ( !is_null( $current ) ) // && array_key_exists( '__hook_', $current ) )
			{
				foreach ( preg_grep_keys( "/__hook_[0-9]?/", $current ) as $hook )
				{
					if ( array_key_exists( $hook, $this->hooks ) )
					{
						$hook = $this->hooks[$hook];
						$result = BindingBuilder::call( $hook['callable'], is_array( $params ) ? $params : ['payload' => $params] );
						if ( !is_null( $result ) )
						{
							if ( $halt )
								return $result;
							else if ( is_array( $result ) )
								$results = array_merge_recursive( $results, $result );
							else
								$results[] = $result;
						}
					}
				}
			}
		}

		return $halt ? null : $results;
	}
1262898
public function notify($event, $payload)
    {
        $result = null;

        foreach ($this->handlers as $condition => $handlers) {
            if ('*' === $condition || ($condition & $event) === $event) {
                foreach ($handlers as $handler) {
                    if ($clause = $this->clauses[spl_object_hash((object) $handler)] ?? null) {
                        if ($clause->intercepted($payload)) {
                            continue;
                        }
                    }
                    $response = $this->callHandler($handler, $payload);

                    switch (true) {
                        case $response instanceof TerminateResult:
                            return $response->content;
                        case true === $response:
                            continue 2;
                        case false === $response:
                            break 2;
                        case !empty($response) && !($result instanceof FinallyResult):
                            $result = $response;
                    }
                }
            }
        }

        return $result instanceof FinallyResult ? $result->content : $result;
    }
827791
public function handle($event, $payload)
    {
        list($model) = $payload;

        // Get the action from the event name
        preg_match('#\.(\w+)#', $event, $matches);
        $action = $matches[1];

        // If there is matching callback method on the model, call it, passing
        // any additional event arguments to it
        $method = 'on'.Str::studly($action);
        if (method_exists($model, $method)) {
            return call_user_func_array([$model, $method], array_slice($payload, 1));
        }
    }
1104629
private static function onReceivedMessage(string $event, $data)
    {
        foreach (self::$onMessage[$event] ?? [] as $callback) {
            asyncCall($callback, $data);
        }
    }
174018
public function broadcast(array $channels, $event, array $payload = [])
    {
        $this->pushman->push($event, $channels, $payload);
    }
818004
public function fire($event, $payload=[], $halt=false)
    {
        return $this->dispatcher->fire($event, $payload, $halt);
    }
27224
public function has($event)
    {
        list($event, $payload) = $this->parseEventAndPayload($event, []);

        return array_key_exists($event, $this->listeners);
    }