Dispatches an event by dispatching arguments to all listeners that handle
the event and returning their return values.

@param   string  The event name
@param   object|array   An array, a AnConfig or a AnEvent object
@return  AnEventDispatcher
162182
public function dispatchEvent($name, $event = array())
    {
        $result = array();
        
        //Make sure we have an event object
        if (! $event instanceof AnEvent) {
            $event = new AnEvent($event);
        }
        
        $event->setName($name)->setDispatcher($this);
             
        //Nofity the listeners
        if (isset($this->_listeners[$name])) {
            foreach ($this->_listeners[$name] as $listener) {
                $listener->$name($event);
                
                if (! $event->canPropagate()) {
                    break;
                }
            }
        }
        
        return $this;
    }
272533
public static function dispatch(string $className, object $object = null) : void
    {
        /** @var EventInterface $className */
        static::eventClassCheck($className);
        $className::dispatch($object);
    }
1089401
protected <E> void dispatchEvent(E event, Collection<Throwable> errors) {

    @SuppressWarnings({ "unchecked", "rawtypes" })
    Class<E> eventType = (Class) event.getClass();
    EventDispatcher<? super E> eventDispatcher = getEventDispatcherOptional(eventType);
    boolean dispatched = false;
    if (eventDispatcher != null) {
      dispatched = eventDispatcher.handleEvent(event, errors);
    }
    if (!dispatched) {
      handleUndispatchedEvent(event);
    }
  }
888424
public function _dispatch($event, $args = array())
    {
        if($event != "onLog") {
            Log::d("Event " . $event, array('events'));
        }
        $eventResult = new EventResult();
        global $context;
        $buffer = array();
        if (!is_array($args)) {
            $args = array($args);
        }
        if (isset($this->handlers[$event]) && count($this->handlers[$event]) > 0) {
            $handlers = $this->handlers[$event];
            foreach ($handlers as $item) {
                $eventResult->addHandler($item);
                $result = $item->run($args);
                if($result !== false) {
                    $eventResult->addResult($result, $item);
                }
            }
        }
        return $eventResult;
    }
713015
public function dispatchEvent($event, $parameters = array()) {
        if (is_string($event)) {
            $event = new BaseEvent($event, $parameters);
        }
        $eventName = $event->getName();
        $event->setDispatcher($this);
        if ($this->hasListeners($eventName)) {
            foreach($this->_listeners[$eventName] as $priority=>$listeners) {
                foreach($listeners as $listener) {
                    if ($event->isPropagationStopped($priority)) {
                        break;
                    }
                    call_user_func($listener, $event);
                }
            }
        }
        return $event;
    }
851103
public function dispatch($name, Event $event = null)
    {
        if (! $this->hasListener($name)) return;

        if (! $event) $event = new Event();
        $event->setDispatcher($this);
        $event->setName($name);

        foreach ($this->getListners($name) as $listener) {
            call_user_func($listener, $event);
            if ($event->isStop()) break;
        }
    }
27263
public function create(ConfigCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $config = new ConfigModel();

        $config->setDispatcher($dispatcher)
            ->setName($event->getEventName())
            ->setValue($event->getValue())
            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())
            ->setHidden($event->getHidden())
            ->setSecured($event->getSecured())
        ->save();

        $event->setConfig($config);
    }
316985
public function initDispatcher()
    {
        $this->di->set('dispatcher', function() {
            $dispatcher = new Dispatcher();

            /**
             * @var \Phalcon\Events\Manager $eventsManager
             */
            $eventsManager = $this->di->getShared('eventsManager');
            $eventsManager->attach(
                'dispatch:beforeException',
                (new ExceptionListener())->beforeException()
            );

            $dispatcher->setEventsManager($eventsManager);

            return $dispatcher;
        });
    }
1340925
public function dispatch(Event $event) {

		$this->lastEvent = $event;
		$eventName = $event->getName();

		if (isset($this->registry[$eventName])) {

			foreach ($this->getSortedRegistry($eventName) as $listener) {
				call_user_func($listener, $event);
			}
			
		}

	}
259401
public function onEvent(Event $anyEvent, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (isset($this->propagations[$eventName])) {
            foreach ($this->propagations[$eventName] as $builder) {
                $builder->buildAndForwardEvent($anyEvent);
            }
        }
    }
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;
	}
1226032
function _dispatch(events, data) {
    var i,
        j,
        i_end,
        j_end,
        event,
        eventName,
        eArray = Array.isArray(events) ?
                   events :
                   events.split(/ /);

    data = data === undefined ? {} : data;

    for (i = 0, i_end = eArray.length; i !== i_end; i += 1) {
      eventName = eArray[i];

      if (_handlers[eventName]) {
        event = {
          type: eventName,
          data: data || {}
        };

        for (j = 0, j_end = _handlers[eventName].length; j !== j_end; j += 1)
          try {
            _handlers[eventName][j].handler(event);
          } catch (e) {}
      }
    }
  }
1010897
function dispatchEvent(event) {
    var type = event.type;
    var listeners = this._eventListeners[type] || [];

    for (var i = 0; i < listeners.length; i++) {
      if (typeof listeners[i] == "function") {
        listeners[i].call(this, event);
      } else {
        listeners[i].handleEvent(event);
      }
    }

    return !!event.defaultPrevented;
  }
1186231
public function dispatchEvent($eventName, EventInterface $event = null)
    {
        $this->getEventDispatcher()->dispatch($eventName, $event);
        
        return $this;
    }
347151
function dispatchEvent(event, handlers) {
    for (var i = (handlers.length - 1); i >= 0; i--) {
        if (event.isPropagationStopped()) {
            break;
        }
        var returnValue = handlers[i](event);
        if (returnValue === false) {
            event.stopPropagation();
            event.preventDefault();
        }
    }
}
1217405
function Dispatcher(emitter, events) {
  if (!(this instanceof Dispatcher)) return new Dispatcher(emitter, events);

  assert(emitter instanceof EventEmitter, 'simple-dispatcher: emitter should be an EventEmitter');
  assert('object' == typeof events, 'simple-dispatcher: events should be an object');

  // iterate over keys in event
  // and map the cb values to the emitter.

  Object.keys(events).forEach(function(key) {
    var arr = Array.isArray(events[key]) ? events[key] : [events[key]];
    arr.forEach(function(cb) {
      emitter.on(key, cb);
    });
  });
}
535325
public function triggerEvent($event, $args = [])
    {
        foreach ($this->dispatchers as $dispatcher) {
            $event = $dispatcher->triggerEvent($event, $args);
        }

        return $event;
    }