このリスナーを実行する

@param   EventInterface  $event
@param   mixed[] $args

@return  mixed
775866
public function trigger(EventInterface $event, array $args = []){
        return call_user_func_array($this->callback, array_merge([$event], $args));
    }
738998
public function subflow(string $event, ...$args)
    {
        if (isset(self::$flows[$event])) {
            $this->triggerFlow(self::$flows[$event], ...$args);
        }

        return $this;
    }
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;
    }
1143705
public function fire(string $event, array $arguments = null) {
        $arguments = (array)$arguments;
        foreach ($this->getBindings($event) as $callback) {
            if (is_callable($callback)) {
                call_user_func_array($callback, $arguments);
            }
        }
    }
646709
public function handle(EventInterface $event)
    {
        $dir = yii::getAlias('@runtime');

        FileHelper::createDirectory($dir);
        file_put_contents($dir . DIRECTORY_SEPARATOR . 'events.log', $this->serializeEvent($event) . PHP_EOL, FILE_APPEND | LOCK_EX);
    }
392337
public function triggerEvent($event, $args = [])
    {
        $dispatcher = $this->getDispatcher();

        if (!$dispatcher instanceof DispatcherInterface) {
            return null;
        }

        $args['mapper'] = $this;

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

        $innerListener = [$this, $event->getName()];

        if (!$event->isStopped() && method_exists($this, $event->getName())) {
            call_user_func($innerListener, $event);
        }

        return $event;
    }
1106622
public function get(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();

        $redirectUrl = $event->getConfig()['indexRedirect'];

        if ($redirectUrl) {
            $response->setStatusCode(307);
            $response->headers->set('Location', $redirectUrl);
            return;
        }

        $response->setStatusCode(200, 'Hell Yeah');

        $baseUrl = $request->getSchemeAndHttpHost() . $request->getBaseUrl();

        $model = new Model\ArrayModel();
        $model->setData([
            'site' => 'http://imbo.io',
            'source' => 'https://github.com/imbo/imbo',
            'issues' => 'https://github.com/imbo/imbo/issues',
            'docs' => 'http://docs.imbo.io',
        ]);

        $response->setModel($model);

        // Prevent caching
        $response->setMaxAge(0)
                 ->setPrivate();
        $response->headers->addCacheControlDirective('no-store');
    }
1228660
public function pong(EventInterface $event, EventQueueInterface $queue)
    {
        $params = $event->getParams();
        $queue->ircPong($params['server1']);
    }
952273
public function subscribe(EventInterface $event) {
        $events = [];

        // Enable the event listener only for resources and methods specified
        foreach ($this->params['allowedMethods'] as $resource => $methods) {
            foreach ($methods as $method) {
                $eventName = $resource . '.' . strtolower($method);
                $events[$eventName] = ['invoke' => 1000];
            }

            // Always enable the listener for the OPTIONS method
            $eventName = $resource . '.options';
            $events[$eventName] = ['options' => 20];
        }

        $manager = $event->getManager();
        $manager->addCallbacks($event->getHandler(), $events);

        // Add OPTIONS to the Allow header
        $event->getResponse()->headers->set('Allow', 'OPTIONS', false);
    }
656821
public function handle(EventInterface $event)
    {

        try {
            // load the application server instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // don't do anything under Windows
            if (FileSystem::getOsIdentifier() === 'WIN') {
                $applicationServer->getSystemLogger()->info('Don\'t switch UID to \'%s\' because OS is Windows');
                return;
            }

            // initialize the variable for user/group
            $uid = 0;
            $gid = 0;

            // throw an exception if the POSIX extension is not available
            if (extension_loaded('posix') === false) {
                throw new \Exception('Can\'t switch user, because POSIX extension is not available');
            }

            // print a message with the old UID/EUID
            $applicationServer->getSystemLogger()->info("Running as " . posix_getuid() . "/" . posix_geteuid());

            // extract the user and group name as variables
            extract(posix_getgrnam($applicationServer->getSystemConfiguration()->getGroup()));
            extract(posix_getpwnam($applicationServer->getSystemConfiguration()->getUser()));

            // switch the effective GID to the passed group
            if (posix_setegid($gid) === false) {
                $applicationServer->getSystemLogger()->error(sprintf('Can\'t switch GID to \'%s\'', $gid));
            }

            // print a message with the new GID/EGID
            $applicationServer->getSystemLogger()->info("Running as group " . posix_getgid() . "/" . posix_getegid());

            // switch the effective UID to the passed user
            if (posix_seteuid($uid) === false) {
                $applicationServer->getSystemLogger()->error(sprintf('Can\'t switch UID to \'%s\'', $uid));
            }

            // print a message with the new UID/EUID
            $applicationServer->getSystemLogger()->info("Running as user " . posix_getuid() . "/" . posix_geteuid());

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
667618
public function trigger($event, $args = array())
	{
		if (!($event instanceof Event))
		{
			if (isset($this->events[$event]))
			{
				$event = $this->events[$event];
			}
			else
			{
				$event = new Event($event);
			}
		}

		// If a listener group was specified
		// lazy load the listeners.
		if ($group = $event->getGroup())
		{
			$this->addListeners($group);
		}

		// Attach any incoming aruments
		foreach ((array) $args as $name => $arg)
		{
			$event->addArgument($name, $arg);
		}

		// Are there any listeners for this event?
		if (isset($this->listeners[$event->getName()]))
		{
			foreach ($this->listeners[$event->getName()] as $listener)
			{
				// Call the event listener
				if ($listener instanceof Closure)
				{
					$response = call_user_func($listener, $event);
				}
				else
				{
					$response = call_user_func(array($listener, $event->getName()), $event);
				}

				// Attach response
				if (!is_null($response))
				{
					$event->addResponse($response);
				}

				// Is propagation stopped?
				if ($event->isStopped())
				{
					break;
				}
			}
		}

		return $event->getResponse();
	}
828022
public function fireReturn(string $event, array $arguments = null) {
        $return = [];
        $arguments = (array)$arguments;

        foreach ($this->getBindings($event) as $callback) {
            if (is_callable($callback)) {
                $return[] = call_user_func_array($callback, $arguments);
            }
        }
        return array_filter($return);
    }
451480
public function handle(EventInterface $event)
    {

        try {
            // load the application server and the naming directory instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();
            /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */
            $namingDirectory = $applicationServer->getNamingDirectory();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // deploy the applications for all containers
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */
            foreach ($applicationServer->getSystemConfiguration()->getContainers() as $containerNode) {
                // load the container instance to deploy the applications for
                /** @var \AppserverIo\Psr\ApplicationServer\ContainerInterface $container */
                $container = $namingDirectory->search(
                    sprintf(
                        'php:services/%s/%s',
                        $applicationServer->runlevelToString(ApplicationServerInterface::NETWORK),
                        $containerNode->getName()
                    )
                );

                // iterate over all applications and shut them down
                /** @var \AppserverIo\Psr\Application\ApplicationInterface $application */
                foreach ($container->getApplications() as $application) {
                    $application->stop();
                }
            }

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
1287203
public function emit($event, $args=null)
    {
        $listers_of_event = isset($this->listeners[$event]) ? $this->listeners[$event] : null;
        if ($listers_of_event){
            foreach ($listers_of_event as $listener){
                call_user_func($listener,$args,$event);
            }
        }
    }
1237957
public function handle(EventInterface $event)
    {
        /* @var \Swoft\Task\Event\Events\BeforeTaskEvent $beforeEvent*/
        $beforeEvent = $event;

        $logid = $beforeEvent->getLogid();
        $spanid = $beforeEvent->getSpanid();
        $method = $beforeEvent->getMethod();
        $taskClass = $beforeEvent->getTaskClass();
        $uri = sprintf('%s->%s', $taskClass, $method);

        $contextData = [
            'logid'       => $logid,
            'spanid'      => $spanid,
            'uri'         => $uri,
            'requestTime' => microtime(true)
        ];
        RequestContext::setContextData($contextData);

        // 日志初始化
        App::getLogger()->initialize();

        // 连接池初始化
    }
517647
public function handle(Event $event)
    {
        // Define Event:
        
        $this->setEvent($event);
        
        // Check Event Name:
        
        if (!$this->hasHandler($event->getName())) {
            
            throw new InvalidArgumentException(
                sprintf(
                    'An event handler does not exist for "%s"',
                    $event->getName()
                )
            );
            
        }
        
        // Handle Event:
        
        $this->{$this->handlers[$event->getName()]}();
    }
1217349
public function onQuickFormEvent($event, $arg, &$caller) {
        if ($event === 'createElement') {
            if (!is_array($arg[2])) {
                $arg[2] = [];
            }
            $arg[2] += array('itemtype' => '', 'component' => '');
        }
        return parent::onQuickFormEvent($event, $arg, $caller);
    }