Invokes associated action to the current request.

@access private

@param int $type request type

@throws FrontControllerException
960445
protected function invokeAction($type = self::MASTER_REQUEST)
    {
        $this->dispatch('frontcontroller.request');

        $request = $this->getRequest();
        $controllerResolver = $this->getApplication()->getContainer()->get('controller_resolver');
        $controller = $controllerResolver->getController($request);

        // logout Event dispatch
        if (
            null !== $request->get('logout')
            && true === $request->get('logout')
            && true === $this->getApplication()->getSecurityContext()->isGranted('IS_AUTHENTICATED_FULLY')
        ) {
            $this->dispatch('frontcontroller.request.logout');
        }

        if (null !== $controller) {
            $dispatcher = $this->application->getEventDispatcher();

            // dispatch kernel.controller event
            $event = new FilterControllerEvent($this, $controller, $request, $type);
            $dispatcher->dispatch(KernelEvents::CONTROLLER, $event);

            // a listener could have changed the controller
            $controller = $event->getController();

            $eventName = $this->getControllerActionEventName($controller[0], $request->attributes->get('_action'));
            $dispatcher->dispatch($eventName.'.precall', new Event\PreRequestEvent($request));

            // get controller action arguments
            $actionArguments = $controllerResolver->getArguments($request, $controller);

            $response = call_user_func_array($controller, $actionArguments);
            if (!($response instanceof Response)) {
                $this->application->warning(sprintf(
                    'Action %s from controller %s should return an object Response, got %s.',
                    $request->attributes->get('_action'),
                    get_class($controller[0]),
                    gettype($response)
                ));

                $response = new Response();
            }
            $dispatcher->dispatch($eventName.'.postcall', new Event\PostResponseEvent($response, $request));

            return $response;
        } else {
            throw new FrontControllerException(
                sprintf('Unknown action `%s`.', $request->attributes->get('_action')),
                FrontControllerException::BAD_REQUEST
            );
        }
    }
759831
public function start($type)
    {
        if ($this->enabled) {
            $this->start = microtime(true);

            $this->hydrations[++$this->currentHydration]['type'] = $type;
        }
    }
410621
protected function invokeControllerAction(AbstractController $controller, $action)
    {
        $this->invokePluginsHook(
            'beforeActionInvoked',
            array($this, $this->getRequest(), $controller, $action)
        );
        $response = $controller->$action($this->routeParams);
        if (null === $response) {
            // if the action returns null, we simply render the default view
            $response = array();
        } elseif (!is_string($response)) {
            // if they don't return a string, try to use whatever is returned
            // as variables to the view renderer
            $response = (array)$response;
        }

        // merge the response variables with the existing view context
        if (is_array($response)) {
            $response = array_merge($controller->getViewContext(), $response);
        }

        // whatever we have as a response needs to be encapsulated in an
        // AbstractResponse object
        if (!($response instanceof AbstractResponse)) {
            $response = new Response($response);
        }
        $this->invokePluginsHook(
            'afterActionInvoked',
            array($this, $this->getRequest(), $controller, $action, $response)
        );
        return $response;
    }
1111160
public function run(int $type = WEBHOOK)
    {
        if ($type == WEBHOOK) {
            $this->_is_webhook = true;
            $this->init();
            $this->processWebhookUpdate();
            return;
        }

        if ($type == DEBUG) {
            $this->debug = true;
        }

        $this->init();
        $this->getUpdatesLocal();
    }
456654
protected function _execute($type, $data)
    {
        if (!isset($this->_handles[$type]))
        {
            $this->_tmp_handles = array();
            $path = \Swoole::$app_path.'/events/'.$type.'.php';
            if (is_file($path))
            {
                $_conf = include $path;
                if ($_conf and isset($_conf['handlers']) and is_array($_conf['handlers']))
                {
                    foreach ($_conf['handlers'] as $h)
                    {
                        if (class_exists($h))
                        {
                            $object = new $h;
                            if ($object instanceof IFace\EventHandler)
                            {
                                $this->_tmp_handles[] = $object;
                                continue;
                            }
                        }
                        trigger_error("invalid event handler[$type|$h]", E_USER_WARNING);
                    }
                }
            }
            $this->_handles[$type] = $this->_tmp_handles;
        }

        foreach($this->_handles[$type] as $handler)
        {
            /**
             * @var  $handler  IFace\EventHandler
             */
            $handler->trigger($type, $data);
        }
        return true;
    }
1045338
protected function call( $type, $params ) {
		if ( !isset( $this->callbacks[$type] ) ) {
			return;
		}
		foreach ( $this->callbacks[$type] as $callback ) {
			if ( is_callable( $callback ) ) {
				call_user_func_array( $callback, $params );
			}
		}
	}
204560
protected function getControllerActions($type, $id, $module, &$result)
    {
        $token = "Create controller with cofig=" . VarDumper::dumpAsString($type) . " and id='$id'";
        Yii::beginProfile($token, __METHOD__);
        try {
            /* @var $controller \yii\base\Controller */
            $controller = Yii::createObject($type, [$id, $module]);
            $this->getActionRoutes($controller, $result);
            $all = "/{$controller->uniqueId}/*";
            $result[$all] = $all;
        } catch (\Exception $exc) {
            Yii::error($exc->getMessage(), __METHOD__);
        }
        Yii::endProfile($token, __METHOD__);
    }
224721
public function addFromRequest(Type $type, Request $request)
    {
        $key = parent::addFromRequest($type, $request);

        return $this->saveFromRequest($key, $request);
    }
942847
public function run($type = 'default')
    {
        $this->stdout("dump {$type}:\n", Console::FG_GREEN);
        switch ($type) {
            case 'default':
                foreach ($this->ipv4->getQueries() as $name => $query) {
                    $this->dumpDefault($query, $name);
                }
                break;
            case 'division':
                foreach ($this->ipv4->getQueries() as $name => $query) {
                    $this->dumpDivision($query, $name);
                }
                break;
            case 'division_id':
                foreach ($this->ipv4->getQueries() as $name => $query) {
                    if (FileQuery::is_a($query)) {
                        $this->dumpDivisionWithId($query, $name);
                    }
                }
                break;
            default:
                $this->stderr("Unknown type \"{$type}\".\n", Console::FG_GREY, Console::BG_RED);
                break;
        }
    }
330724
public function onActivity($type = null)
    {

        Breadcrumbs::register('logger-activity', function($breadcrumbs) {
            $breadcrumbs->push('Activity Log', handles('antares::logger/activity/index'));
        });
        if (!is_null($type)) {
            Breadcrumbs::register('logger-activity-' . $type, function($breadcrumbs) use($type) {
                $breadcrumbs->push(ucfirst($type) . ' Log', handles('antares::logger/activity/' . $type));
            });
            view()->share('breadcrumbs', Breadcrumbs::render('logger-activity-' . $type));
        } else {
            view()->share('breadcrumbs', Breadcrumbs::render('logger-activity'));
        }
    }
820089
public function handle(SymfonyRequest $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        try {
            $this->getApplication()->share('request', $request);
            return $this->handleRaw($request, $type);
        } catch (Exception $e) {
            $this->reportException($e);
            $response = $this->renderException($request, $e);
        } catch (Throwable $e) {
            $this->reportException($e = new FatalThrowableError($e));
            $response = $this->renderException($request, $e);
        }
//        event(new Events\RequestHandled($request, $response));
        return $response;
    }
201148
private function load($type)
    {
        $index = $this->$type;
        if ($index) {
            return;
        }

        $cache = $this->di->get("cache");
        $key = $cache->createKey(__CLASS__, $type);
        $index = $cache->get($key);

        if (is_null($index) || $this->ignoreCache) {
            $createMethod = "create$type";
            $index = $this->$createMethod();
            $cache->put($key, $index);
        }

        $this->$type = $index;
    }
842553
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
    {
        if (!$this->booted) {
            $this->boot();
        }

        $current = HttpKernelInterface::SUB_REQUEST === $type ? $this->container['request'] : $this->container['request_error'];

        $this->container['request'] = $request;
        $this->flush();

        $response = $this->container['kernel']->handle($request, $type, $catch);

        $this->container['request'] = $current;

        return $response;
    }
547926
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        while ($route = $this->router->route($request)) {
            $module     = $route->getPayload()['module'];
            $controller = $route->getPayload()['controller'];
            $action     = $route->getPayload()['action'];
            $class      = str_replace(
                ['{:module}', '{:controller}'],
                [$module, $controller],
                $this->mapping
            );
            try {
                return $this->assetManager->resolve($class, ['invoke' => $action]);
            } catch (\LogicException $e) {
                $this->failures[] = ['route' => $route, 'exception' => $e];
            }
        }
    }
512016
public function start($type = '*firefox', $startUrl = 'http://localhost')
    {
        if (null !== $this->sessionId) {
            throw new Exception("Session already started");
        }

        $response = $this->doExecute('getNewBrowserSession', $type, $startUrl);

        if (preg_match('/^OK,(.*)$/', $response, $vars)) {
            $this->sessionId = $vars[1];
        } else {
            throw new Exception("Invalid response from server : $response");
        }
    }
421774
public function onAddedToType(TypeInterface &$type)
    {
        parent::onAddedToType($type);

        if ($this->getAddIndex()) {
            $type->addIndex(new Index($this->name));
        }

        $type->addTrait(UpdatedAtInterface::class, UpdatedAtInterfaceImplementation::class)->serialize($this->name);
    }
340006
protected function _callAnnotation(Controller &$class, $annotation = [], $type = 'class', $annotationType = 'Before') {
        foreach ($annotation[$type] as $action => $annotationClasses) {
            foreach ($annotationClasses as $annotationClass) {
                if ($annotationClass['annotation'] == $annotationType) {
                    /** @var \Gcs\Framework\Core\Annotation\Annotations\Common\Before $instance */
                    $instance = $annotationClass['instance'];

                    $className = $instance->class;
                    $methodName = $instance->method;

                    if (method_exists($className, $methodName)) {
                        if ($className == get_class($class)) {
                            $class->$methodName();
                        }
                        else {
                            $reflectionMethod = new \ReflectionMethod($className, $methodName);
                            echo $reflectionMethod->invoke(new $className());
                        }
                    }
                    else {
                        throw new MissingMethodException('The method "' . $methodName . '" from the class "' . $className . '" does not exist');
                    }
                }
            }
        }
    }