Overwrite default SSViewer call to get a custom
template list

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

        // Prepare action for template search
        if ($action == "index") {
            $action = "";
        } else {
            $action = '_' . $action;
        }

        $templates = array_merge(
            // Find templates by dataRecord
            SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"),
            // Now get templates for sitetree
            SSViewer::get_templates_by_class(Page::singleton(), $action, "SilverStripe\\CMS\\Model\\SiteTree"),
            // Next, we need to add templates for all controllers
            SSViewer::get_templates_by_class(static::class, $action, "SilverStripe\\Control\\Controller"),
            // Fail-over to the same for the "index" action
            SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"),
            SSViewer::get_templates_by_class(static::class, "", "SilverStripe\\Control\\Controller")
        );

        return SSViewer::create($templates);
    }
302230
private function getDefaultVars(Template $template = null, $controller, $action)
    {
        if (0 !== count($arguments = $template->getVars())) {
            return $arguments;
        }

        if (!$template instanceof ViewAnnotation || $template->isPopulateDefaultVars()) {
            $r = new \ReflectionObject($controller);

            $arguments = array();
            foreach ($r->getMethod($action)->getParameters() as $param) {
                $arguments[] = $param->getName();
            }

            return $arguments;
        }
    }
744264
public function perPage(string $action = null): string
    {
        return $this->htmlRenderer->perPage($this->request, $action);
    }
616235
public function Link($action = null)
    {
        $id = ($this->section) ? $this->section->ID : null;
        $segment = Controller::join_links('section', $id, $action);
        if ($page = Director::get_current_page()) {
            return $page->Link($segment);
        }
        return Controller::curr()->Link($segment);
    }
127708
protected function getApiUrl($action, $queryParams)
    {
        $baseUrl = strtr($this->urlTemplate, [
            '{subdomain}' => $this->subdomain
        ]) . $action;

        if (!empty($queryParams)) {
            return  $baseUrl . '?' . http_build_query($queryParams);
        } else {
            return $baseUrl;
        }
    }
940156
public function Link($action = null)
    {
        return Controller::join_links(
            parent::Link(),
            $this->config()->url_segment,
            $action
        );
    }
325440
protected function getActionPath(string $action): string
    {
        $modelName = $this->getModelName();
        $viewName  = $modelName.ucfirst($action).'.js';

        return resource_path('assets/admin/src/views/'.pluralize($modelName).'/'.$viewName);
    }
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']);
    }
59285
protected function convertToControllerAction($action)
    {
        if (is_string($action)) {
            $action = ['uses' => $action];
        }
        
        // Here we'll merge any group "uses" statement if necessary so that the action
        // has the proper clause for this property. Then we can simply set the name
        // of the controller on the action and return the action array for usage.
        if (! empty($this->groupStack)) {
            $action['uses'] = $this->prependGroupUses($action['uses']);
        }
        
        // Here we will set this controller name on the action array just so we always
        // have a copy of it for reference if we need it. This can be used while we
        // search for a controller name or do some other type of fetch operation.
        $action['controller'] = $action['uses'];
        
        return $action;
    }
644077
protected function createView($action='view')
    {
        $controller = \Staq\Util::getStackSubQuery($this);
        $view = (new \Stack\View)->byName($action, $controller);
        $view['controller'] = $controller;
        $view['controllerAction'] = $action;
        return $view;
    }
1226752
public function beforeAction($action)
    {
        $itemName = '';
        $controller = $action->controller;

        /**
         * @var \yii\web\User $user
         */
        $user = \Yii::$app->getUser();

        if ($user->isGuest) {
            $user->loginRequired();
        }

        if (($module = $controller->module) !== null) {
            $itemName .= $module->id . '.';
            if ($user->can($itemName . '*')) {
                return true;
            }
        }

        $itemName .= $controller->id;
        if ($user->can($itemName . '.*')) {
            return true;
        }

        $itemName .= '.' . $action->id;
        if ($user->can($itemName, $this->params)) {
            return true;
        }

        throw new HttpException(401, \Yii::t('yii', 'You are not permission to perform this action.'));
    }
748552
public function Link($action = null)
    {
        if ($this->data()->virtualOwner) {
            $controller = ElementController::create($this->data()->virtualOwner);

            return $controller->Link($action);
        }

        return parent::Link($action);
    }
1065220
protected function getActionUrl($action) : string
    {
        $context = Context::getInstance();
        return $context->getUrl($context->getParameter('controller_path') . $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);
    }
677438
public function actionResolver($action)
    {
        if(is_string($action)) {
            $this->setFunctionName(Str::camel($action));
        } elseif (is_callable($action)) {
            $this->setCallback($action);
        } else {
            $this->setData($action);
        }

        return $this;
    }
132081
public function beforeAction($action)
    {
        if (!$this->enableDebugLogs) {
            foreach ($this->get('log')->targets as $target) {
                $target->enabled = false;
            }
        }

        if (!parent::beforeAction($action)) {
            return false;
        }

        // do not display debug toolbar when in debug view mode
        Yii::$app->getView()->off(View::EVENT_END_BODY, [$this, 'renderToolbar']);
        Yii::$app->getResponse()->off(Response::EVENT_AFTER_PREPARE, [$this, 'setDebugHeaders']);

        if ($this->checkAccess($action)) {
            $this->resetGlobalSettings();
            return true;
        }

        if ($action->id === 'toolbar') {
            // Accessing toolbar remotely is normal. Do not throw exception.
            return false;
        }

        throw new ForbiddenHttpException('You are not allowed to access this page.');
    }
1348420
protected function _setViewSettings($action) {
        $authVars = Garp_Auth::getInstance()->getConfigValues();

        if (!isset($authVars[$action])) {
            return;
        }
        $authVars = $authVars[$action];
        $module = isset($authVars['module']) ? $authVars['module'] : 'default';
        $moduleDirectory = $this->getFrontController()
            ->getModuleDirectory($module);
        $viewPath = $moduleDirectory . '/views/scripts/';

        $this->view->addScriptPath($viewPath);
        $view = isset($authVars['view']) ? $authVars['view'] : $action;
        $this->_helper->viewRenderer($view);
        $layout = isset($authVars['layout']) ? $authVars['layout'] : 'layout';
        if ($this->_helper->layout->isEnabled()) {
            $this->_helper->layout->setLayoutPath($moduleDirectory . '/views/layouts');
            $this->_helper->layout->setLayout($layout);
        }
    }