Dispatch an event

@param  string $eventName An event name
@param  Event  $event
@return int    return code of the executed script if any, for php scripts a false return
value is changed to 1, anything else to 0
778460
public function dispatch($eventName, Event $event = null)
    {
        if (null == $event) {
            $event = new Event($eventName);
        }

        return $this->doDispatch($event);
    }
1177643
public static function run(String $eventName, Array $parameters = []) : Bool
    {
        return Run::event($eventName, $parameters);
    }
194159
private function doRender(Map $map, $eventName)
    {
        $this->getEventDispatcher()->dispatch($eventName, $event = new MapEvent($map));

        return $event->getCode();
    }
117643
protected function getListeners($eventName)
    {
        if (isset($this->listeners[$eventName])) {
            return $this->listeners[$eventName];
        }
        return null;
    }
21450
private function executeListeners($eventName) {
        $listeners = $this->eventConfig[$eventName];
        foreach ($listeners as $listener) {
            $return = $this->classInvoker->invoke($listener);

            //如果某个事件监听器返回“false”，则停止事件的传播
            if ($return === false) {
                break;
            }
        }
    }
581030
protected function getHandlers($eventName)
    {
        return isset($this->events[$eventName]) ? $this->events[$eventName] : new CallbackQueue();
    }
947632
public function handle(Event $event)
    {
        $name = $event->getName();
        list(, $method) = explode('.', $name);
        if (empty($this->_config['for']) && empty($this->_config['when'])) {
            return $this->{$method}($event);
        }
        if ($this->matches($event)) {
            return $this->{$method}($event);
        }
    }
743755
public function getEventLogInfo(Event $event, $eventName)
    {
        $this->default = array(
            'type' => $eventName,
            'description' => $eventName,
        );

        if (!isset($this->commands[$eventName])) {
            return $this->default;
        }

        return $this->getEventLogDetails($event, $this->commands[$eventName]);
    }
382284
public function onModeScriptCallbackArray($eventName, $parameters)
    {
        $parameters = $this->parseParameters($parameters);
        $this->dispatcher->dispatch($eventName, [$parameters]);
    }
544095
public function dispatch($eventName, sfEvent $event = null)
    {
        if (null !== $this->application) {
            $this->application->debug(sprintf('Dispatching `%s` event.', $eventName));
        }

        return parent::dispatch($eventName, $event);
    }
119168
public function runHandler(Event $event)
    {
        if (is_callable($this->handler)) {
            return call_user_func($this->handler, $event);
        }
        return false;
    }
506318
public function dispatch($eventName, $params)
    {
        if (isset($this->enabledProviderListeners[$eventName])) {
            foreach ($this->enabledProviderListeners[$eventName] as $callback) {
                call_user_func_array($callback, $params);
            }
        }
    }
1143160
protected function fireEvent($eventName, Event $event)
    {
        if (!$this->eventDispatcher) {
            throw new \BadMethodCallException(sprintf(
                'Method %s() cannot be used while event dispatcher is not configured.',
                __METHOD__
            ));
        }

        $this->eventDispatcher->dispatch($eventName, $event);
    }
611101
public function dispatch($eventName, EventArguments $arguments = null)
    {
        if (false === $this->hasListeners($eventName)) {
            return $this;
        }
        $arguments = $arguments ?: EventArguments::createEmpty();
        foreach ($this->getListeners($eventName) as $listener) {
            $listener->$eventName($arguments);
        }
        return $this;
    }
626379
public function onEvent(Event $event, $eventName)
    {
        foreach ($this->dataCollectors as $dataCollector) {
            $dataCollector->collect($event, $eventName);
        }
    }
1087492
protected function call($eventName, $method, $data = null)
    {
        if (method_exists($this, $method)) {
            $result = call_user_func_array([$this, $method], $data);
            return $result;
        }

        return null;
    }
1366364
public function dispatch($event_name, Event $event)
    {
        $dir = $this->events_dir.$event_name.'/';

        if (!file_exists($dir)) {
            mkdir($dir, 0755, true);
        }

        $event = serialize($event);
        file_put_contents($dir.md5($event).'.meta', $event);
    }