Return an SSViewer object to render the template for the current page.

@param $action string

@return SSViewer
975162
public function getViewer($action)
    {
        // Manually set templates should be dealt with by Controller::getViewer()
        if (!empty($this->templates[$action])
            || !empty($this->templates['index'])
            || $this->template
        ) {
            return parent::getViewer($action);
        }

        // Prepare action for template search
        $action = $action === 'index' ? '' : '_' . $action;

        $templatesFound = [];
        // Find templates for the record + action together - e.g. Page_action.ss
        if ($this->dataRecord instanceof SiteTree) {
            $templatesFound[] = $this->dataRecord->getViewerTemplates($action);
        }

        // Find templates for the controller + action together - e.g. PageController_action.ss
        $templatesFound[] = SSViewer::get_templates_by_class(static::class, $action, Controller::class);

        // Find templates for the record without an action - e.g. Page.ss
        if ($this->dataRecord instanceof SiteTree) {
            $templatesFound[] = $this->dataRecord->getViewerTemplates();
        }

        // Find the templates for the controller without an action - e.g. PageController.ss
        $templatesFound[] = SSViewer::get_templates_by_class(static::class, "", Controller::class);

        $templates = array_merge(...$templatesFound);
        return SSViewer::create($templates);
    }
1139356
public function _canExecute($action)
    {
        $viewer = get_viewer();

        if ($viewer->hasSubscription()) {
            $ret = $this->getItem()->authorize('upgradepackage');
        } else {
            $ret = $this->getItem()->authorize('subscribepackage');
        }

        return $ret;
    }
814904
public function view($request) {
		$object = null;
		if ($id = $request->param('ID')) {
			$object = ExternalContent::getDataObjectFor($id);
			if ($object instanceof ExternalContentSource) {
				$object = $object->getRoot();
			}

			if ($object && ($object instanceof ExternalContentItem || $object instanceof ExternalContentSource)) {
				$this->data()->setRequestedItem($object);
				$type = $object instanceof ExternalContentItem ? $object->getType() : 'source';
				$template = 'ExternalContent_' . get_class($object) . '_' . $type;

				$viewer = new SSViewer(array($template, 'ExternalContent_' . get_class($object), 'ExternalContent', 'Page'));
				$action = 'view';
				$this->extend('updateViewer', $action, $viewer);

				return $this->customise($object)->renderWith($viewer);
			}
		}

		echo "Template not found for " . ($object ? get_class($object) . ' #' . $object->ID : '');
	}
479227
function getViewer($action)
    {
        if ($this->parentController) {
            if (is_numeric($action)) {
                $action = 'view';
            }
            $viewer = $this->parentController->getViewer($action);
            $layoutTemplate = null;
            // action-specific template with template identifier, e.g. themes/mytheme/templates/Layout/MyModel_view.ss
            $layoutTemplate = SSViewer::getTemplateFileByType("{$this->recordType}_$action", 'Layout');

            // generic template with template identifier, e.g. themes/mytheme/templates/Layout/MyModel.ss
            if (!$layoutTemplate) {
                $layoutTemplate = SSViewer::getTemplateFileByType($this->recordType, 'Layout');
            }

            // fallback to controller classname, e.g. iwidb/templates/Layout/NestedModelController.ss
            $parentClass = static::class;
            while ($parentClass != Controller::class && !$layoutTemplate) {
                $layoutTemplate = SSViewer::getTemplateFileByType("{$parentClass}_$action", 'Layout');
                if (!$layoutTemplate) {
                    $layoutTemplate = SSViewer::getTemplateFileByType($parentClass, 'Layout');
                }
                $parentClass = get_parent_class($parentClass);
            }

            $viewer->setTemplateFile('Layout', $layoutTemplate);

            return $viewer;
        } else {
            return parent::getViewer($action);
        }
    }
1030788
public function beforeAction($action)
    {
        if (in_array($this->action->id, ['notify', 'return', 'cancel', 'proxy-notification'], true)) {
            Yii::$app->controller->enableCsrfValidation = false;
        }

        return parent::beforeAction($action);
    }
107110
private function getControllerLogic($action)
    {
        list($class, $method) = getClassAndMethodFromString($action);
        $controllerClass = fixClassname(Router::$namespace, $class);

        //Todo: Dependency Injection
        /* @var $controller Controller */
        $controller = new $controllerClass();
        if (!$controller instanceof Controller) {
            throw new Exception("$class does not extend Controller");
        }
        $this->controllerMiddleware = $controller->getMiddlewares();
        return function ($request) use ($controller, $method) {
            //Todo: Dependency Injection
            return $controller->$method($request);
        };
    }
882853
protected function template($action, $params = null) {
		
		if(false === is_string($action)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($action)), E_USER_ERROR);
		}
		
		if(null !== $params && false === is_array($params)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR);
		}

		$functions = TemplateData :: getTemplateFunctions();

		if(false === isset($functions[$action])) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be a valid callable template function, "%s" given', __METHOD__, $action), E_USER_ERROR);
		}

		return call_user_func_array($functions[$action], $params);
	}
255927
public function renderAction(Action $action, array $parameters = []): Response
    {
        return $this->baseTemplatingHelper->renderAction($action, $parameters);
    }
412699
public function Link($action='') {
		if (strlen($this->ExternalURL) && !strlen($this->Content)) {
			// redirect away
			return $this->ExternalURL;
		}
		if ($this->InternalFile()->ID) {
			$file = $this->InternalFile();
			return $file->Link($action);
		}
		return parent::Link($action);
	}
1116384
protected function createView($action, $type)
    {
        $view = (new \Stack\View)->byName($type, 'Model_' . ucfirst($action));
        $view['controller'] = $type;
        $view['controllerAction'] = $action;
        return $view;
    }
1048694
public function getActionUrl($action)
    {
        if (is_array($action->urlData) && $this->isOpenNewWindow)
        {
            $action->url = BackendUrlHelper::createByParams($action->urlData)
                ->enableEmptyLayout()
                ->enableNoActions()
                ->params
            ;
        };

        return $action->url;
    }
328192
protected function renderAction(array $parameters = [], Action $action = null)
    {
        $response = new Response();
        $response->setContent($this->getTemplate($action)->render($parameters));

        return $response;
    }
786104
public function filter($action = 'set') {
        $role = $this->Roles->newEntity();
        if ($this->request->session()->check('Roles')) {
            $session = $this->request->session()->read('Roles');
            $role = $this->Roles->patchEntity($role,  $session);
        }
        if ($this->request->is(['patch', 'post', 'put'])) {
            if ($action == 'unset') {
                $this->request->session()->delete('Roles');
            } else {
                $this->request->session()->write('Roles', $this->request->data);
            }
            $this->Flash->success(__('The role has been saved.'));
            return $this->redirect(['action' => 'index']);
        }
        $this->set(compact('role'));
        $this->set('_serialize', ['role']);
    }
695820
protected function getTemplateFile(string $action = null) : string
    {
        $path = '/controller/' . lcfirst($this->getControllerName()) . '/';

        return $path . ($action ? $action : $this->getActionName());
    }
581621
public function Link($action = null)
    {
        /** @skipUpgrade */
        $link = Controller::join_links(Director::baseURL(), "Security", $action);
        $this->extend('updateLink', $link, $action);
        return $link;
    }
426891
public static function getMethodFromAction(string $action): string
    {
        $method = str_replace(['.', '-', '_'], ' ', $action);
        $method = ucwords($method);
        $method = str_replace(' ', '', $method);
        $method = lcfirst($method);
        $method .= 'Action';
        return $method;
    }
651909
public function render($action = null)
    {
        $action = is_null($action) ? $this->controller->action : $action;
        if (strpos($action, '/') === false) {
            $view_filename = VIEWS_DIR . $this->controller->name . '/' . $action . static::$ext;
        } else {
            $view_filename = VIEWS_DIR . $action . static::$ext;
        }
        $content = static::extract($view_filename, $this->vars);
        $this->controller->output .= $content;
    }