Configures the view encoder based on the current options.
@param array $options The current options.
@param string $controller The controller to use for the default view.
@param string $action The action to use for the default view.
14804
private function configureViewEncoder($options, $controller, $action)
    {
        // configure the view encoder if they specify a view option
        if (isset($options[self::KEY_VIEWS])) {
            $this->encoder = new TwigViewEncoder(
                $options[self::KEY_VIEWS],
                sprintf('%s/%s.twig', $controller, $action)
            );
        } else {
            $this->encoder = new NullEncoder();
        }
    }
344054
public function handleAction($action, $actionParams)
    {
        $this->setView($action);
        $response = parent::handleAction($action, $actionParams);

        if ($response instanceof Response) {
            return $response;
        }

        if (is_string($response)) {
            $this->controllerView->content = $response;
        } elseif (isset($this->view)) {
            $this->controllerView->content = $this->view->render();
        }

        $this->response->setContent($this->controllerView->render());

        return $this->response;
    }
580395
private function _callAction(Controller $controller, $action, $error)
    {
        if ($error) {
            $method = $this->actionChain->actionNameStrategy($action . '_' . $error);
        } else {
            $method = $this->actionChain->actionNameStrategy($action);
        }
        if (method_exists($controller, $method)) {
            return $controller->$method();
        } else {
            return $error;
        }
    }
818548
protected function resource($name, $controller, array $options = [])
    {
        $this->router->resource($name, $controller, $options);
    }
242883
public function initCron($src, $controller, $action) {
        if (!Config::config()['user']['debug']['maintenance']) {
            $this->_routeCron($src, $controller, $action);

            if ($this->_route == true) {
                $this->_setFunction($this->request->src);
                $this->_setEvent($this->request->src);
            }
        }
    }
1082003
public function resource($name, $controller, array $options = array())
    {
        $registrar = $this->getRegistrar();

        $registrar->register($name, $controller, $options);
    }
961438
public function setAction(Controller $controller, $action = 'execute')
    {
        $this->controller = $controller;
        $this->action = $action;
    }
593390
public static function process($options = []) {
		// start buffering
		\Helper\Ob::start(true);
		$controller_class = self::$settings['mvc']['controller_class'];
		// processing options
 		if (!empty($options)) {
			foreach ($options as $k => $v) {
				self::$controller->{$k} = $v;
			}
 		}
		// put action into controller
		self::$controller->action_code = self::$settings['mvc']['controller_action_code'];
		self::$controller->action_method = self::$settings['mvc']['controller_action'];
		// check ACL
		if ($controller_class != '\Controller\Errors') {
			if (!self::$controller->permitted(['redirect' => true])) {
				Throw new \Exception('Permission denied!', -1);
			}
		}
		// auto populating input property in controller
 		if (!empty(self::$settings['application']['controller']['input'])) {
			self::$controller->input = \Request::input(null, true, true);
 		}
		// init method
		if (method_exists(self::$controller, 'init')) {
			call_user_func(array(self::$controller, 'init'));
		}
		// check if action exists
		if (!method_exists(self::$controller, self::$controller->action_method)) {
			Throw new \Exception('Action does not exists!');
		}
		// calling action
		echo call_user_func(array(self::$controller, self::$controller->action_method));
		// auto rendering view only if view exists, processing extension order as specified in .ini file
		$temp_reflection_obj = new ReflectionClass(self::$controller);
		$controller_dir = pathinfo($temp_reflection_obj->getFileName(), PATHINFO_DIRNAME) . '/';
		$controller_file = end(self::$settings['mvc']['controllers']);
		$view = self::$settings['mvc']['controller_view'];
		$flag_view_found = false;
		if (!empty($view)) {
			$extensions = explode(',', isset(self::$settings['application']['view']['extension']) ? self::$settings['application']['view']['extension'] : 'html');
			foreach ($extensions as $extension) {
				$file = $controller_dir  . $controller_file . '.' . $view . '.' . $extension;
				if (file_exists($file)) {
					$view_object = new \View(self::$controller, $file, $extension);
					$flag_view_found = true;
					break;
				}
			}
			// if views are mandatory
			if (!empty(self::$settings['application']['view']['mandatory']) && !$flag_view_found) {
				Throw new \Exception('View ' . $view . ' does not exists!');
			}
		}
		// autoloading media files
		\Layout::includeMedia($controller_dir, $controller_file, $view, $controller_class);
		// appending view after controllers output
		self::$controller->data->view = (self::$controller->data->view ?? '') . \Helper\Ob::clean();
		// if we have to render debug toolbar
		if (\Debug::$toolbar) {
			\Helper\Ob::start();
		}
		// call pre rendering method in bootstrap
		\Bootstrap::preRender();
		// rendering layout
		$__skip_layout = self::get('flag.global.__skip_layout');
		if (!empty(self::$settings['mvc']['controller_layout']) && empty($__skip_layout)) {
			\Helper\Ob::start();
			if (file_exists(self::$settings['mvc']['controller_layout_file'])) {
				$layout_object = new \Layout(self::$controller, self::$settings['mvc']['controller_layout_file'], self::$settings['mvc']['controller_layout_extension']);
			}
			// session expiry dialog before replaces
			\Session::expiryDialog();
			// buffer output and handling javascript files, chicken and egg problem
			$from = [
				'<!-- [numbers: messages] -->',
				'<!-- [numbers: title] -->',
				'<!-- [numbers: document title] -->',
				'<!-- [numbers: actions] -->',
				'<!-- [numbers: breadcrumbs] -->',
				'<!-- [numbers: javascript links] -->',
				'<!-- [numbers: javascript data] -->',
				'<!-- [numbers: css links] -->',
				'<!-- [numbers: layout onload] -->',
				'<!-- [numbers: layout onhtml] -->',
				'<!-- [numbers: workflows] -->'
			];
			$to = [
				\Layout::renderMessages(),
				\Layout::renderTitle(),
				\Layout::renderDocumentTitle(),
				\Layout::renderActions(),
				\Layout::renderBreadcrumbs(),
				\Layout::renderJs(),
				\Layout::renderJsData(),
				\Layout::renderCss(),
				\Layout::renderOnload(),
				\Layout::$onhtml,
				\Object\Form\Workflow\Base::render()
			];
			echo str_replace($from, $to, \Helper\Ob::clean());
		} else {
			echo self::$controller->view;
		}
		// headers
		if (!empty(self::$settings['header']) && !headers_sent()) {
			foreach (self::$settings['header'] as $k => $v) {
				header($v);
			}
		}
		// ajax calls that has not been processed by application
		if (self::get('flag.global.__ajax')) {
			\Layout::renderAs(['success' => false, 'error' => [\I18n(null, 'Could not process ajax call!')]], 'application/json');
		}
	}
60368
final public function forward(string $controller, $action = null) :void {

		// get the current route as a base
		$route = Router::getCurrentRoute();
		
		// and alter it
		$route->controller	= $controller;
		$route->action		= $action;
		
		// forward to the new route
		Router::forward($route);
		
	}
863483
protected function executePhpAction(Config\Action $action) : void
    {
        $this->beforeAction();
        $runner = new Action\PHP();
        $runner->execute($this->config, $this->io, $this->repository, $action);
        $this->afterAction();
    }
315885
public function setController(Controller $controller)
    {
        $this->links->controller = $controller;
        $this->twig->addGlobal('controller', $this->links->controller);
    }
807951
public function Link($action = null)
    {
        if ($this->shortcodableclass) {
            return Controller::join_links(
                $this->config()->url_base,
                $this->config()->sc_url_segment,
                'edit',
                $this->shortcodableclass
            );
        }
        return Controller::join_links($this->config()->url_base, $this->config()->sc_url_segment, $action);
    }
631627
protected function setEditRoute($controller, $action): Controller
    {
        $callTo = Inflector::classify($controller) . '@' . $action;

        $this->routes['get'] = array_merge($this->routes['get'], [
            "/$controller/$action/{:id}/" => $callTo,
        ]);

        $this->routes['post'] = array_merge($this->routes['post'], [
            "/$controller/$action/" => $callTo,
        ]);
        
        $this->routes['post'] = array_merge($this->routes['post'], [
            "/$controller/$action/{:id}/" => $callTo,
        ]);

        return $this;
    }
731647
public function patch(string $uri, string $controller, string $action)
    {
        $this->addRoute('PATCH', $uri, $controller, $action);
    }
286038
protected function overrideView($action) {
        $overrides = Configure::read('Admin.viewOverrides');
        $model = $this->Model->qualifiedName;
        $view = in_array($action, array('create', 'update')) ? 'form' : $action;

        if (empty($overrides[$model][$action])) {
            $this->render($view);
            return;
        }

        $override = $overrides[$model][$action] + array(
            'action' => $view,
            'controller' => $this->name,
            'plugin' => null
        );

        // View settings
        $this->view = $override['action'];
        $this->viewPath = Inflector::camelize($override['controller']);
        $this->plugin = Inflector::camelize($override['plugin']);

        // Override
        $this->request->params['override'] = true;

        $this->render();
    }
140055
protected function fillOptions($options): void
    {
        $this->uri = $options['uri'] ?? '/';
        $this->namespace = $options['namespace'] ?? config('jsonrpc.controllerNamespace', 'App\\Http\\Controllers\\Api\\');
        $this->postfix = $options['postfix'] ?? config('jsonrpc.controllerPostfix', 'Controller');
        $this->description = $options['description'] ?? config('jsonrpc.description', 'JsonRpc Server');
        $this->controller = $options['controller'] ?? config('jsonrpc.defaultController', 'Api');
        $this->middleware = $options['middleware'] ?? config('jsonrpc.middleware', [MethodClosureMiddleware::class]);
        $this->acl = $options['acl'] ?? config('jsonrpc.acl', []);
        $this->auth = $options['auth'] ?? config('jsonrpc.authValidate', true);
        $this->handlers = $options['handlers'] ?? config('jsonrpc.handlers', self::DEFAULT_HANDLERS);
        $this->endpoint = $options['endpoint'] ?? null;
        $this->action = $options['action'] ?? null;
    }
273766
protected function _setLayout(Controller &$controller) {
		$isModal = $controller->request->is('modal');
		$isPopup = $controller->request->is('popup');
		$isSSE = $controller->request->is('sse');
		$isPrint = $controller->request->is('print');
		if ($isModal || $isPopup || $isSSE) {
			$controller->layout = 'CakeTheme.default';
		} elseif ($isPrint) {
			$controller->viewPath = mb_ereg_replace(DS . 'prt', '', $controller->viewPath);
			$controller->response->type('html');
		}
	}