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);
    }
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);
    }
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 ) ; }
Return an SSViewer object to render the template for the current page.

@param $action string

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