Calls the hooks stored at the given event name (if any exist) and
passes them the given parameters.

@param string $event
@param array $params
@return \m\Foundation\Core
348072
public function call($event, array $params = array())
    {

        // Include an instance of this object as the final argument
        $params[] = $this;

        if (isset($this->_hooks[$event])) {
            foreach($this->_hooks[$event] as $hook) {
                call_user_func_array($hook, $params);
            }
        }

        return $this;
    }
1114563
public function dispatch($event/*, string $eventName = null*/)
    {
        $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null;

        if (\is_object($event)) {
            $eventName = $eventName ?? \get_class($event);
        } else {
            @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), E_USER_DEPRECATED);
            $swap = $event;
            $event = $eventName ?? new Event();
            $eventName = $swap;

            if (!$event instanceof Event) {
                throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an instance of %s, %s given.', EventDispatcherInterface::class, Event::class, \is_object($event) ? \get_class($event) : \gettype($event)));
            }
        }

        if (null !== $this->optimized && null !== $eventName) {
            $listeners = $this->optimized[$eventName] ?? (empty($this->listeners[$eventName]) ? [] : $this->optimizeListeners($eventName));
        } else {
            $listeners = $this->getListeners($eventName);
        }

        if ($listeners) {
            $this->callListeners($listeners, $eventName, $event);
        }

        return $event;
    }
92916
public function setEvent($event = [])
    {
        if (!empty($event['id'])) {
            $this->setLogs($event['id'], 'campaignEventId');
        }
        $overrides = [];
        if (!empty($event['config']['contactclient_overrides'])) {
            // Flatten overrides to key-value pairs.
            $jsonHelper = new JSONHelper();
            $array      = $jsonHelper->decodeArray($event['config']['contactclient_overrides'], 'Overrides');
            if ($array) {
                foreach ($array as $field) {
                    if (!empty($field->key) && !empty($field->value) && (empty($field->enabled) || true === $field->enabled)) {
                        $overrides[$field->key] = $field->value;
                    }
                }
            }
            if ($overrides) {
                $this->setOverrides($overrides);
            }
        }
        $this->event = $event;

        return $this;
    }
1302565
public function notify($event, $params)
    {
        $observers = $this->getObservers();

        if (isset($observers[$event])) {
            foreach ($observers[$event] as $observer) {
                $observer->setTriggeredEvent($event);
                $observer->setTriggeredEventParams($params);
                $observer->setBag($this->getBag());
                $observer->run();
           }
        }
    }
139024
public function execute(Event $event = null)
    {
        $event = $event ? $event : $this->createEvent();
        $this->logger->info('Starting web hook handle');

        if (!$event->isValid()) {
            $this->logger->error('Found not valid event from '.$event->getHost());
            $this->return404();

            return;
        }

        if (!$this->checkPermissions($event, $this->options)) {
            return;
        }

        $repoName = $event->getRepositoryName();
        $branchName = $event->getBranchName();
        $repository = $this->getRepository($repoName);
        if (!$repository || !($branch = $repository->getBranch($branchName))) {
            $this->logger->warning('Repository: '.$repoName.' and branch: '.$branchName.' not found in the settings');
            $this->return404();

            return;
        }

        $commandResults = $this->commandExecutor->execute(array($this, $repository, $branch));
        $this->sendEmails($event, $commandResults);

        $this->logger->info('End of web hook handle');
    }
965550
protected function trigger($event, ...$arguments)
    {
        if (!empty($this->handlers[$event])) {
            /** @var callable $handler */
            foreach ($this->handlers[$event] as $handler) {
                call_user_func_array($handler, $arguments);
            }
        }
    }
1325022
public static function trigger($event, $params=array())
	{
		if (isset(self::$events[$event]))
		{
			foreach (self::$events[$event] as $item)
			{
				if(true === call_user_func($item,$params))
				{
					// 事件返回true时不继续执行其余事件
					return true;
				}
			}
			return false;
		}
		return true;
	}
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);
        }
    }
849348
public static function ready( $event, $params = array() ) {
		$responses = static::fire( $event, $params );
		
		foreach( static::pack( $responses ) as $response ) {
			if ( $response !== true ) {
				return false;
			}
		}
		
		return true;
	}
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;
    }
256226
protected function fireServerEvent(string $event, array $params)
    {
        /** @var array[] $collector */
        $collector = ServerListenerCollector::getCollector();

        if (!isset($collector[$event]) || empty($collector[$event])) {
            return;
        }

        foreach ($collector[$event] as $beanClass) {
            $listener = App::getBean($beanClass);
            $method = SwooleEvent::getHandlerFunction($event);
            $listener->$method(...$params);
        }
    }
140039
public static function run($hook, array $params = array())
    {
        // Make sure the hook index exists
        if (!isset(static::$plugins[$hook])) {
            return false;
        }

        // Run the hook
        foreach (static::$plugins[$hook] as $plugin) {
            call_user_func_array($plugin, $params);
        }
    }
993281
public function getHooks(string $event): array
	{
		return isset(static::$traitHooks[static::class][$event]) ? $this->bindHooks(static::$traitHooks[static::class][$event]) : [];
	}
673113
function triggerModeScriptEvent($event, $params = '', $multicall = false)
    {
        if (!is_string($event)) {
            throw new InvalidArgumentException('event name must be a string: event = ' . print_r($event, true));
        }

        if (is_string($params)) {
            return $this->execute(ucfirst(__FUNCTION__), array($event, $params), $multicall);
        }

        if (is_array($params)) {
            foreach ($params as $param) {
                if (!is_string($param)) {
                    throw new InvalidArgumentException('argument must be a string: param = ' . print_r($param, true));
                }
            }
            return $this->execute(ucfirst(__FUNCTION__) . 'Array', array($event, $params), $multicall);
        }

        // else
        throw new InvalidArgumentException('argument must be string or string[]: params = ' . print_r($params, true));
    }
787473
public function fireEvent($name, $params = null)
    {
        $handleList = Utility::get($this->events, $name, null);
        $result = true;
        if ($handleList) {
            foreach ($handleList as $methodName) {
                if (gettype($methodName) == "string") {
                    $return = $this->$methodName($params);
                } else {
                    $return = $methodName($params);
                }
                $result &= ($return !== null) ? $return : true;
            }
        }
        //Allow to write event handle in the report
        if (method_exists($this, $name)) {
            $return = $this->$name($params);
            $result &= ($return !== null) ? $return : true;
        }
        return $result;
    }
431341
@Override
	public void handleEvent(String event, Map<ISFSEventParam, Object> params) {
		handleExtendedEvent(event, new SFSEvent(null, params));
	}
1102309
public function update(string $hook, array $params = [])
    {
        $path = $this->buildHooksPath($hook);

        return $this->put($path, $params);
    }