Invoke the listeners for an event.

@param string         $name
@param EventInterface $event
@param array          $arguments

@return void
495016
protected function invokeListeners($name, EventInterface $event, array $arguments)
    {
        $listeners = $this->getListeners($name);

        foreach ($listeners as $listener) {
            if ($event->isPropagationStopped()) {
                break;
            }

            call_user_func_array([$listener, 'handle'], $arguments);
        }
    }
375875
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());

            // and initialize a console for each node found in the configuration
            /** @var \AppserverIo\Psr\Cli\Configuration\ConsoleConfigurationInterface $consoleNode */
            foreach ($applicationServer->getSystemConfiguration()->getConsoles() as $consoleNode) {
                /** @var \AppserverIo\Appserver\Core\Interfaces\ConsoleFactoryInterface $consoleFactory */
                $consoleFactory = $consoleNode->getFactory();

                // use the factory if available
                /** @var \AppserverIo\Appserver\Core\Interfaces\ConsoleInterface $console */
                $console = $consoleFactory::factory($applicationServer, $consoleNode);

                // register the console as service
                $applicationServer->bindService(ApplicationServerInterface::ADMINISTRATION, $console);
            }

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
382284
public function onModeScriptCallbackArray($eventName, $parameters)
    {
        $parameters = $this->parseParameters($parameters);
        $this->dispatcher->dispatch($eventName, [$parameters]);
    }
1046701
public function _call(string $name, &...$arguments)
    {
        $method = $this->getReflection()->getMethod($name);
        $method->setAccessible(true);

        return $method->invokeArgs($this->getInstance(), $arguments);
    }
46008
protected function emitWithoutCancellingPropagationCheck(string $eventName, array $arguments = []): void
    {
        foreach ($this->getEventSubscribers($eventName) as $subscriber) {
            call_user_func_array($subscriber, $arguments);
        }
    }
308473
public function addEvent($name, EventInterface $event)
    {
        $this->container->get('bldr.dispatcher')->dispatch($name, $event);

        return $this;
    }
165863
public function execute($eventName, $object)
    {
        if (isset($this->events[$eventName]) && is_array(($this->events[$eventName]))) {
            foreach ($this->events[$eventName] as $method) {
                call_user_func([$object, $method]);
            }
        }
    }
711338
function emit(string $event, ...$arguments) {
        if(!empty($this->listeners[$event])) {
            foreach($this->listeners[$event] as $listener) {
                $listener(...$arguments);
            }
        }
        
        if(!empty($this->onceListeners[$event])) {
            $listeners = $this->onceListeners[$event];
            unset($this->onceListeners[$event]);
            
            foreach($listeners as $listener) {
                $listener(...$arguments);
            }
        }
    }
694842
public function handle(EventInterface $event)
    {

        try {
            // load the application server and the naming directory 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());

            // add the configured extractors to the internal array
            /** @var \AppserverIo\Appserver\Core\Api\Node\ScannerNodeInterface $scannerNode */
            foreach ($applicationServer->getSystemConfiguration()->getScanners() as $scannerNode) {
                // load the factory class name
                $factoryClass = $scannerNode->getFactory();

                // invoke the visit method of the factory class
                /** @var \AppserverIo\Appserver\Core\Scanner\ScannerFactoryInterface $factory */
                $factoryClass::visit($applicationServer, $scannerNode);
            }

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
906311
public static function fire($name)
	{
		$args = func_get_args();
		unset($args[0]);

		if (isset(self::$events[$name]))
		{
			foreach (self::$events[$name] as $event)
			{
				if (is_callable($event))
				{
					call_user_func_array($event, $args);
				}
			}
		}
	}
1367652
public function fireEvents(string $name, QueryObject $queryObject, array $eventArguments = []): void
    {
        $this->connection->getEventHandler()->fireEvents($name, $queryObject, $this, $eventArguments);
    }
26004
public function listen($name, $listenerInterface)
    {

        $name = is_object($name) ? get_class($name) : $name;

        if ($listenerInterface instanceof EventListener && $listenerInterface instanceof SubscriberInterface) {
            $listeners = $listenerInterface->getSubscribedEvents();

            foreach ($listeners as $listener => $callback) {
                if (!$callback instanceof Closure) {
                    $callback = [$listenerInterface, $callback];
                }

                if(is_integer($listener)){
                    EventCollector::addListener($name, $callback);

                }else{
                    EventCollector::addListener($name.'.'.$listener, $callback);
                }
            }

        } else {
            EventCollector::addListener($name, $listenerInterface);
        }

        return $this;
    }
1188938
public function triggerAndCount($name, ...$args)
    {
        if ($this->addThisToEvents) {
            array_unshift($args, $this);
        }
        $cnt = 0;
        if (isset($this->eventHandlers[$name])) {
            $this->lastEventName = $name;
            foreach ($this->eventHandlers[$name] as $cb) {
                if ($cb(...$args) !== 0) {
                    ++$cnt;
                }
            }
        }
        return $cnt;
    }
639465
public function addListener(string $eventName, $listener) : void
    {
        $this->dispatcher->addListener($eventName, $listener);
    }
284078
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()
                    )
                );

                // load the containers deployment
                /** @var \AppserverIo\Psr\Deployment\DeploymentInterface $deployment */
                $deployment = $container->getDeployment();
                $deployment->injectContainer($container);

                // deploy and initialize the container's applications
                $deployment->deploy();
            }

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
249959
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());

            // load the service instance and switch the umask
            /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */
            $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\DeploymentService');
            $service->initUmask($applicationServer->getSystemConfiguration()->getUmask());

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
1115036
public static function trigger($name, array $args = array())
    {
        if ($name === 'error') {
            self::$state = 5;
        }

        if (empty(self::$events[$name])) {
            return null;
        }

        $listen = self::$events[$name];

        usort($listen, function ($a, $b) {
            return $b[1] >= $a[1];
        });

        foreach ($listen as $callback) {
            call_user_func_array($callback[0], $args);
        }

        $listen = null;
    }