Creates a new Action using the passed parameters.

@param array  $parameters Passed parameters
@param string $controller Default controller to use if none is provided
@return mixed
166099
public function create(array $parameters, $controller = null) {
        $parameters = $this->parseParameters($parameters, $controller);

        $action = new Action(
            $parameters['name'],
            $parameters['pattern'],
            $parameters['uses'],
            $parameters['group']
        );

        $this->setProperties($action, $parameters);

        return $action;
    }
504487
protected function makeController($controller)
    {
        Controller::setRouter($this->router);

        $controller = $this->container->make($controller);

        if ( ! $controller instanceof AdminPageController)
        {
            if ($this->container->isShared('post'))
            {
                $controller->setPost($this->container['post']);
            }

            $controller->setQuery($this->container['query']);
        }

        if (method_exists($controller, 'boot'))
        {
            $this->container->call([$controller, 'boot']);
        }

        return $controller;
    }
69000
private function callClassController($controller, $action)
    {
        if (!class_exists($controller)) {
            throw new AppException(sprintf('Invalid class name or class "%s" does not exists', $controller));
        }

        $instance = new $controller($this);

        if ($res = $this->callMethod($instance, 'before')) {
            return $res;
        }

        if (false === $response = $this->callMethod($instance, $action)) {
            throw new AppException(sprintf('Unable to call action "%s" on controller "%s"', $action, $controller));
        }

        if ($res = $this->callMethod($instance, 'after')) {
            return $res;
        }

        return $response;
    }
702825
protected function redirectHere($action, $parameters = [])
    {
        $controller = get_class($this);

        return Redirect::action($controller.'@'.$action, $parameters);
    }
381681
protected function prepareCallController($controller, $newRequest)
    {
        $controller = parent::prepareCallController($controller, $newRequest);
        $controller->setView($this->getView());

        return $controller;
    }
602437
public function callAction($method, $parameters)
    {
        $route = app('router')->current();
        $request = app('request');
        $this->assignAfter($route, $request, $method);
        $response = $this->before($route, $request, $method);

        if (is_null($response)) {
            $response = call_user_func_array([$this, $method], $parameters);
        }

        return $response;
    }
351014
public function startup($controller = null)
    {
        if (!$controller) {
            $controller = new Controller(new Request());
        }
        $registry = new ComponentRegistry();
        $this->Acl = new AclComponent($registry, Configure::read('Acl'));
        $this->Aco = $this->Acl->Aco;
        $this->controller = $controller;
        $this->_buildPrefixes();
        $this->_processIgnored();
    }
1194156
protected function execute($action, array $parameters = [])
    {
        $parameters += $this->input;

        return $this->server->dispatch(
            new ServerRequest($action, $parameters)
        )->getData();
    }
1121413
protected function createController($controller)
    {
        if (false === strpos($controller, '::')) {
            throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
        }

        list($class, $method) = explode('::', $controller, 2);

        if ($this->container->has($class)) {
            $controller = $this->container->get($class);
        } else {
            if ( ! class_exists($class)) {
                throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
            }

            $controller = new $class();
        }

        if ($controller instanceof ContainerAwareInterface) {
            $controller->setContainer($this->container);
        }

        return array($controller, $method);
    }
720442
protected function _buildActionArgs($controller, $action, $params)
    {
        $args = [];
        $missing = [];

        $di = $this->_di;

        $parameters = (new \ReflectionMethod($controller, $action . 'Action'))->getParameters();
        foreach ($parameters as $parameter) {
            $name = $parameter->getName();
            $value = null;

            $type = $parameter->getClass();
            if ($type !== null) {
                $type = $type->getName();
            } elseif ($parameter->isDefaultValueAvailable()) {
                $type = gettype($parameter->getDefaultValue());
            }

            if ($className = ($c = $parameter->getClass()) ? $c->getName() : null) {
                if ($di->has($name)) {
                    $value = $di->get($name);
                } elseif ($di->has($className)) {
                    $value = $di->get($className);
                } else {
                    $value = $di->getShared($className);
                }
            } elseif (isset($params[$name])) {
                $value = $params[$name];
            } elseif ($this->request->has($name)) {
                $value = $this->request->get($name);
            } elseif (count($params) === 1 && count($parameters) === 1) {
                $value = $params[0];
            } elseif ($parameter->isDefaultValueAvailable()) {
                $value = $parameter->getDefaultValue();
            }

            if ($value === null) {
                $missing[] = $name;
                continue;
            }

            switch ($type) {
                case 'boolean':
                    $value = (bool)$value;
                    break;
                case 'integer':
                    $value = (int)$value;
                    break;
                case 'double':
                    $value = (float)$value;
                    break;
                case 'string':
                    $value = (string)$value;
                    break;
                case 'array':
                    $value = (array)$value;
                    break;
            }

            if ($parameter->isArray()) {
                $args[] = (array)$value;
            } else {
                $args[] = $value;
            }
        }

        if ($missing) {
            throw new MissingRequiredFieldsException($missing);
        }

        return $args;
    }
662872
public function generate($controller)
    {
        $generator = new Generator(
            $this->setting->getControllerDirectory(),
            $controller
        );

        if ($generator->fileExists()) {
            echo "\033[0;31mThe controller already exists.\033[00m\n";

            exit(1);
        }

        if ($this->arg->options('--no-plain')) {
            $generator->write('controller/no-plain', [
                'baseNamespace' => $this->namespaces['controller']
            ]);
        } else {
            $generator->write('controller/controller', [
                'baseNamespace' => $this->namespaces['controller']
            ]);
        }

        echo "\033[0;32mThe controller was well created.\033[00m\n";

        exit(0);
    }
839088
protected function configureController(Controller $controller)
    {
        $controller->setInput($this->getInput())
            ->setOutput($this->getOutput())
            ->setCommand($this->getCommand());
        $composer = new Composer();
        $controller->add($composer);
    }
343823
public function handleController($controller, $method)
    {
        if($this->app->findController($controller)) {
            $controllerClass = "App\\Controller\\".$controller;
            $this->controller = new $controllerClass();
        }
        if($this->app->hasMethod($this->controller, $method)) {
            self::$instance = $this;
            ob_start();
            $return = $this->controller->$method();
            $output = ob_get_clean();
            self::$instance = null;
        }
        if($return !== null) {
            //handle returned value
        }
        $output = $output ?: null;
        return $output;
    }
95120
protected function bindToController($request, $url, $controller)
    {
        $array  = explode('|', $url, 2);
        $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action');
        $param  = [];

        if (!empty($array[1])) {
            $this->parseUrlParams($request, $array[1], $param);
        }

        return new ControllerDispatch($request, $this, $controller . '/' . $action, $param);
    }
1361389
public function makeAction(array $parameters, FactoryInterface $factory = null) {
        if($factory === null) {
            $factory = $this->getDefaultActionFactory();
        }

        if(!isset($parameters['group'])) {
            $parameters['group'] = new Group($this->getRouteName(), $this->getRoutePattern());
        }

        $action = $factory->create($parameters, $this->getController());

        $this->addAction($action);

        return $action;
    }
741138
public function create(array $parameters) {
        $toolbarItem = new VoidButtonToolbarItem($parameters['label'], $parameters['action']);
        unset($parameters['label'], $parameters['action']);
        foreach($parameters as $key => $value) {
            $toolbarItem->$key = $value;
        }
        return $toolbarItem;
    }
1043074
public function invoke($controller, $command)
    {
        $commandMethod = $command . 'Command';

        if (!method_exists($controller, $commandMethod)) {
            throw new NotFoundException([
                '`:controller:::action` is not found',
                'action' => $commandMethod,
                'controller' => get_class($controller)
            ]);
        }

        $args = $this->_buildArgs($controller, $command);

        switch (count($args)) {
            case 0:
                $r = $controller->$commandMethod();
                break;
            case 1:
                $r = $controller->$commandMethod($args[0]);
                break;
            default:
                $r = call_user_func_array([$controller, $commandMethod], $args);
                break;
        }

        return $r;
    }