Reset the theme and output for a new context. This only makes sense from
external::validate_context(). Do not cheat.

@return string the name of the theme that should be used on this page.
517049
public function reset_theme_and_output() {
        global $COURSE, $SITE;

        $COURSE = clone($SITE);
        $this->_theme = null;
        $this->_wherethemewasinitialised = null;
        $this->_course = null;
        $this->_cm = null;
        $this->_module = null;
        $this->_context = null;
    }
1133085
public function get_context() {
        if (isset($this->context)) {
            return $this->context;
        }
        $this->context = \context::instance_by_id($this->data['contextid'], IGNORE_MISSING);
        return $this->context;
    }
309160
public function reset()
    {
        $this->itemsPerPage = null;
        $this->currentPage = null;
        $this->totalAmount = null;
        $this->url = null;

        return $this;
    }
1222313
public function reset()
	{
		$this->_current_cfg = [];
		$this->_cfg = [];
    $this->_root_element = false;
    $this->_current_element = false;
		foreach ( $this->_defaults as $k => $v ){
			$this->_current_cfg[$k] = $v;
		}
    return $this;
	}
871425
public function editAction()
    {
        $themeId = $this->getEvent()->getRouteMatch()->getParam('themeId');
        $theme = $this->getAdminThemeService()->findById($themeId);

        $form = $this->getServiceLocator()->get('playgrounddesign_theme_form');

        $request = $this->getRequest();

        $form->bind($theme);

        if ($request->isPost()) {
            $data = array_merge(
                $request->getPost()->toArray(),
                $request->getFiles()->toArray()
            );

            $theme = $this->getAdminThemeService()->edit($data, $theme, 'playgrounddesign_theme_form');

            if ($theme) {
                $this->flashMessenger()->addMessage('The theme "'.$theme->getTitle().'" was updated');

                return $this->redirect()->toRoute('admin/playgrounddesign_themeadmin');
            } else {
                $this->flashMessenger()->addMessage('The theme was not updated');

                return $this->redirect()->toRoute('admin/playgrounddesign_themeadmin');
            }
        }

        $viewModel = new ViewModel();
        $viewModel->setTemplate('playground-design/theme-admin/theme');

        return $viewModel->setVariables(array('form'           => $form,
                                              'automaticTheme' => 0));
    }
191770
protected function get_behat_contexts_for_theme($theme) : array {
        // If we already have this list then just return. This will not change by run.
        if (!empty($this->themecontexts[$theme])) {
            return $this->themecontexts[$theme];
        }

        try {
            $themeconfig = $this->get_theme_config($theme);
        } catch (Exception $e) {
            // This theme has no theme config.
            return [];
        }

        // The theme will use all core contexts, except the one overridden by theme or its parent.
        $parentcontexts = [];
        if (isset($themeconfig->parents)) {
            foreach ($themeconfig->parents as $parent) {
                if ($parentcontexts = $this->get_behat_contexts_for_theme($parent)) {
                    break;
                }
            }
        }

        if (empty($parentcontexts)) {
            $parentcontexts = $this->get_components_contexts();
        }

        // Remove contexts which have been actively blacklisted.
        $blacklistedcontexts = $this->get_blacklisted_tests_for_theme($theme, 'contexts');
        foreach ($blacklistedcontexts as $blacklistpath) {
            $blacklistcontext = basename($blacklistpath, '.php');

            unset($parentcontexts[$blacklistcontext]);
        }

        // Apply overrides.
        $contexts = array_merge($parentcontexts, $this->get_tests_for_theme($theme, 'contexts'));

        // Remove classes which are overridden.
        foreach ($contexts as $contextclass => $path) {
            require_once($path);
            if (!class_exists($contextclass)) {
                // This may be a Poorly named class.
                continue;
            }

            $rc = new \ReflectionClass($contextclass);
            while ($rc = $rc->getParentClass()) {
                if (isset($contexts[$rc->name])) {
                    unset($contexts[$rc->name]);
                }
            }
        }

        // Sort the list of contexts.
        ksort($contexts);

        $this->themecontexts[$theme] = $contexts;

        return $contexts;
    }
1017773
public function _setActiveTheme()
    {
        if (empty($this->config['theme'])) {
            return;
        }

        if (!is_array($this->config['theme'])) {
            $template   = $this->config['theme'];
            $stylesheet = $this->config['theme'];
        } else {
            $template   = reset($this->config['theme']);
            $stylesheet = end($this->config['theme']);
        }

        $GLOBALS['wp_tests_options']['template']   = $template;
        $GLOBALS['wp_tests_options']['stylesheet'] = $stylesheet;

        codecept_debug('Set template to [' . $template . '] and stylesheet to [' . $stylesheet . ']');
    }
233826
public function defaultAction()
    {
        $themeName = $this->params()->fromRoute('theme');
        if (! $themeName) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('Theme was not specified.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/theme')
                ->setStatusCode(303);
        }
        $side = $this->params()->fromRoute('side', 'frontend');
        $service = $this->getThemeService();
        if (! $service->setDefault($themeName, $side)) {
            foreach ($service->getMessages() as $message) {
                $this->flashMessenger()->addMessage($message);
            }
        }
        return $this->redirect()->toRoute('sc-admin/theme');
    }
813416
protected function renderSetOriginalFileName()
    {
        $columnsSetters = array();
        if ($this->getParameter('use_origin_fileName')) {
            foreach ($this->getColumns() as $column) {
                $columnsSetters[$column] = $this->getColumnSetter($this->getOriginalNameColumn($column));
            }

            if (count($columnsSetters)) {
                return $this->renderTemplate("setOriginalFileName", array('columnsSetters' => $columnsSetters));
            }
        }
        return '';
    }
83237
public function getRequiredThemedCSS()
    {
        $css =  $this->config()->required_themed_css;
        
        $this->extend('updateRequiredThemedCSS', $css);
        
        return $this->processCSSConfig($css);
    }
566267
public function reset()
    {

        $result = WpOption::updateOrCreate(
            ['option_name' => $this->optionsName],
            ['option_value' => json_encode( $this->optionsData )]
        );


        $this->_value = (array) $mergeOptions;

        return $result;

    }
618970
public static function setup_theme() {

		global $pagenow;

		if ( ( is_admin() && 'themes.php' == $pagenow ) || ! self::can_switch_themes() ) {
			return;
		}

		self::check_reset();
		self::load_cookie();

		if ( empty( self::$theme ) ) {
			return;
		}

		add_filter( 'pre_option_template', array( self::$theme, 'get_template' ) );
		add_filter( 'pre_option_stylesheet', array( self::$theme, 'get_stylesheet' ) );
		add_filter( 'pre_option_stylesheet_root', array( self::$theme, 'get_theme_root' ) );
		$parent = self::$theme->parent();
		add_filter( 'pre_option_template_root', array( empty( $parent ) ? self::$theme : $parent, 'get_theme_root' ) );
		add_filter( 'pre_option_current_theme', '__return_false' );
	}
530383
protected function getFrontendThemesSettings()
    {
        $themes = $this->module->getByType('theme', true);
        unset($themes[$this->theme_backend]);
        return $themes;
    }
1176863
public function getCommandContext()
    {
        $context = parent::getCommandContext();
        $context->response = $this->getResponse();
        $context->request = $this->getRequest();

        return $context;
    }
140941
protected function getDefaultTheme()
    {
        if (!is_null($this->default) && array_key_exists($this->default, $this->themes)) {
            return $this->themes[$this->default];
        }

        return false;
    }
1319489
public function toHtml()
    {
        // load the theme and context (site) configs
        $this->getContextConfig();
        $this->getThemeConfig();

        $filename = $this->getTemplateFolder().$this->getTemplate();
        $html = $this->getTemplateFile($filename, $this);
        
        return $html;
    }
885938
public function getAreaLayoutColumnOffsetEditClass()
    {
        /*
         * @var ThemeGridLayout $this->arLayout
         */
        $gf = $this->arLayout->getThemeGridFrameworkObject();
        if (is_object($gf)) {
            $class = $gf->getPageThemeGridFrameworkColumnAdditionalClasses();
            if ($class) {
                $class .= ' ';
            }

            $class .= $gf->getPageThemeGridFrameworkColumnClassForSpan($this->arLayoutColumnOffset);

            return $class;
        }
    }