getController

@param string      $task
@param array|Input $input
@param bool        $forceNew

@return AbstractController
@throws \ReflectionException
772287
public function getController($task, $input = null, $forceNew = false)
    {
        $resolver = $this->getMvcResolver()->getControllerResolver();

        $key = $resolver::getDIKey($task);

        $container = $this->getContainer();

        if (!$container->exists($key) || $forceNew) {
            if ($input !== null && !$input instanceof Input) {
                $input = new Input($input);
            }

            $input = $input ?: $container->get('input');

            try {
                /** @var AbstractController $controller */
                $controller = $resolver->create($task, $input, $this, $container);
                $controller->setApplication($this->app)
                    ->setInput($input)
                    ->setPackage($this)
                    ->setContainer($container);
            } catch (\DomainException $e) {
                throw new RouteNotFoundException($e->getMessage(), 404, $e);
            }

            $container->share($key, $controller);
        }

        return $container->get($key);
    }
348058
public function getToken($forceNew = false)
    {
        /** @var Session $session */
        $session = $this->session;

        $token = $session->get(static::TOKEN_KEY);

        // Create a token
        if ($token === null || $forceNew) {
            $token = $this->createToken(12);

            $session->set(static::TOKEN_KEY, $token);
        }

        return $token;
    }
1049826
public static function action($task)
    {
        //====================================================================//
        // Stack Trace
        Splash::log()->trace();
        Splash::log()->deb("Object => ".$task->name." (".$task->desc.")");

        //====================================================================//
        //  READING OF SERVER OBJECT LIST
        //====================================================================//
        if (SPL_F_OBJECTS === $task->name) {
            return self::doObjects($task);
        }

        //====================================================================//
        // Safety Check - Minimal Parameters
        //====================================================================//
        // Verify Requested Object Type is Available
        if (!self::isValidTask($task)) {
            return self::getEmptyResponse($task);
        }

        //====================================================================//
        // Execute Admin Actions
        //====================================================================//
        if (in_array($task->name, array( SPL_F_DESC , SPL_F_FIELDS , SPL_F_LIST ), true)) {
            return self::doAdminActions($task);
        }
        if (in_array($task->name, array( SPL_F_GET , SPL_F_SET , SPL_F_DEL ), true)) {
            return self::doSyncActions($task);
        }
        if (in_array($task->name, array( SPL_F_COMMIT ), true)) {
            Splash::log()->war("Objects - Requested task not found => ".$task->name);

            return self::getEmptyResponse($task);
        }
        //====================================================================//
        // Task Not Found
        Splash::log()->err("Objects - Requested task not found => ".$task->name);

        return self::checkResponse(self::getEmptyResponse($task));
    }
895881
private function createWorkload(TaskInterface $task)
    {
        // TODO get from additional form of handler
        $workload = [];

        $optionsResolver = new OptionsResolver();
        $optionsResolver->setDefaults(
            [
                'class' => $task->getEntityClass(),
                'id' => $task->getEntityId(),
                'locale' => $task->getLocale(),
            ]
        );

        $handler = $this->taskHandlerFactory->create($task->getHandlerClass());
        if (!$handler instanceof AutomationTaskHandlerInterface) {
            throw new TaskHandlerNotSupportedException($handler, $task);
        }

        $optionsResolver = $handler->configureOptionsResolver($optionsResolver);

        return $optionsResolver->resolve($workload);
    }
381681
protected function prepareCallController($controller, $newRequest)
    {
        $controller = parent::prepareCallController($controller, $newRequest);
        $controller->setView($this->getView());

        return $controller;
    }
782671
private function getController(Container $container): HttpControllerInterface
    {
        try {
            return (new Dispatcher($this->getServerRequest()))
                   ->dispatch($container, $this->router);
        } catch (RouterException $e) {
            throw $e;
        } catch (DispatcherException $e) {
            throw $e;
        } finally {
            unset($this->router);
        }
    }
595176
public static function getDefaultController($module = null, $exception = false) {
        $module = ($module === null) ? static::getDefaultModule() : $module;

        return static::getConfig('modules', $module, 'defaults', 'controller', $exception);
    }
205012
public function getTask(liveTask $task, $throwException = false)
    {
        $data = $this->query($throwException);

        return $this->formatTask($task, $data);
    }
789661
public function run(InputInterface $input, OutputInterface $output)
    {
        parent::run($input, $output);
        $formTask = new GenerateForm(
            [
                'command' => $this->_command,
                'controllerData' => $this->_controllerData,
                'path' => $this->getPath()
            ]
        );
        return $formTask->run($input, $output);
    }
1084348
private function createController(\ReflectionClass $controllerName)
    {
        $controller = $this->container->make($controllerName->getName());
        return $controller;
    }
894610
public function findTaskByType($type)
    {
        foreach ($this->tasks as $task) {
            if ($task->getName() === $type) {
                return $task;
            }
        }

        throw new TaskNotFoundException($type);
    }
797214
public function onKernelController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();

        if($request->attributes->get(self::JGP_AJAX_BLOCK_TAG)) {
            $queryParams = array();

            $controller = $event->getController();
            $reflectionMethod = is_array($controller)
                ? new \ReflectionMethod($controller[0], $controller[1])
                : new \ReflectionFunction($controller);

            $controllerParameters = array_map(function(\ReflectionParameter $parameter) {
                return $parameter->getName();
            }, $reflectionMethod->getParameters());

            $parameters = $request->attributes->all();
            foreach ($parameters as $paramName => $paramValue) {
                if (!in_array($paramName, $controllerParameters)) {
                    $queryParams[$paramName] = $paramValue;
                }
            }

            $request->query->add($queryParams);
        }
    }
862250
private function getAnnotations($forceNew = false) {
        if ($this->annotations === null || $forceNew === true) {
            $this->annotations = new Annotation(get_called_class());
        }

        return $this->annotations;
    }
523615
public function get($name)
    {
        $options = [];
        if (is_array($name)) {
            $options = $name;
            list($name) = array_keys($name);
            $options = $options[$name];
        }

        if (array_key_exists($name, $this->registeredTasks)) {
            /** @var AbstractTask $task */
            $task = $this->registeredTasks[$name];
            $task->setOptions($options);
            return $task;
        } elseif (class_exists($name)) {
            $reflex = new ReflectionClass($name);
            if ($reflex->isInstantiable()) {
                $task = new $name();
                if ($task instanceof AbstractTask) {
                    $task->setOptions($options);
                    $this->add($task);
                    return $task;
                }
            }
        }

        throw new RuntimeException(sprintf('Invalid task name "%s"', $name));
    }
1116745
public function get_label(base_task $task = null) {
        // If a task has been provided and the label is not already set meaningfully
        // we will attempt to improve it.
        if (!is_null($task) && $this->label == $this->setting->get_name() && strpos($this->setting->get_name(), '_include') !== false) {
            if ($this->setting->get_level() == backup_setting::SECTION_LEVEL) {
                $this->label = get_string('includesection', 'backup', $task->get_name());
            } else if ($this->setting->get_level() == backup_setting::ACTIVITY_LEVEL) {
                $this->label = $task->get_name();
            }
        }
        return $this->label;
    }
1304526
protected function getTaskHandle($task)
    {
        // Check the handle if possible
        if (!is_string($task)) {
            return;
        }

        // Compute the handle and check it's bound
        $handle = 'rocketeer.tasks.'.Str::snake(class_basename($task), '-');
        $task = $this->container->has($handle) ? $handle : null;

        return $task;
    }
952165
public function getModel($name = null, $source = null, $forceNew = false)
    {
        return $this->getRepository($name, $source, $forceNew);
    }