Return list of behat contexts for theme and update $this->stepdefinitions list.

@param string $theme theme name.
@return  List of contexts
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;
    }
593191
public function setTheme($theme)
    {
        $this->theme = [];

        foreach ((array) $theme as $path) {
            $this->theme[] = $path === 'default' ? self::$defaultCSS : $path;
        }

        return $this;
    }
600143
protected function getThemes(string $theme)
    {
        try {
            return $this->themes->get($theme, false);
        } catch (\InvalidArgumentException $e) {
            throw new \InvalidArgumentException('Theme \'' . $theme . '\' not found');
        }
    }
448202
public function theme($theme = null)
    {
        deprecationWarning(
            'Email::theme() is deprecated. Use $email->viewBuilder()->getTheme()/setTheme() instead.'
        );

        if ($theme === null) {
            return $this->getTheme();
        }

        return $this->setTheme($theme);
    }
797394
public static function getThemeRegionConfigFor(string $theme, int $contextType) : array
    {
        return array_filter(
            variable_get('ucms_layout_regions_' . $theme, []),
            function ($value) use ($contextType) {
                return $value == $contextType;
            }
        );
    }
1262961
public function absolutePath($theme = null)
    {
        if (is_null($theme)) {
            $theme = $this->getCurrent();
        }

        return $this->config['paths']['absolute'].'/'.$theme;
    }
623626
public function theme_should_be_activated( $theme )
	{
		$theme = $this->replace_variables( $theme );
		$current_theme = $this->get_current_theme();

		if ( $theme !== $current_theme ) {
			throw new \Exception( sprintf(
				"The current theme is %s, but it should be %s",
				$current_theme,
				$theme
			) );
		}
	}
307547
protected function resolveTheme($theme)
    {
        $theme  = $this->where('slug', $theme)->first();
        $parent = null;

        if ($theme->has('parent')) {
            $parent = $this->where('slug', $theme->get('parent'))->first();
        }

        return [$theme, $parent];
    }
1347013
public function readContextCallees(ContextEnvironment $environment, $contextClass)
    {
        $reflClass = new \ReflectionClass($contextClass);

        if (!$reflClass->implementsInterface('Behat\Behat\Context\TranslatableContext')) {
            return array();
        }

        $assetsId = $environment->getSuite()->getName();
        foreach (call_user_func(array($contextClass, 'getTranslationResources')) as $path) {
            $this->addTranslationResource($path, $assetsId);
        }

        return array();
    }
686786
public function getThemeName($theme = null)
	{
		if (Config::get('@.THEME_ON'))
		{
			// 参数传入的主题
			if (is_string($theme) && '' !== $theme)
			{
				return $theme;
			}
			// 类设定的主题
			else if (is_string($this->theme) && '' !== $this->theme)
			{
				return $this->theme;
			}
			// 配置中默认主题
			else
			{
				return Config::get('@.THEME', null);
			}
		}
		else
		{
			return '';
		}
	}
314380
private function loadTemplates(array $themes)
    {
        $templates = array();
        foreach ($themes as $theme) {
            $key = is_object($theme) ? spl_object_hash($theme) : $theme;

            if (!isset($this->templates[$key])) {
                $template = $this->twig->load($theme);

                $this->templates[$key] = $template;
            }

            $templates[] = $this->templates[$key];
        }

        return $templates;
    }
1180611
public static function inTheme($theme)
    {
        if (is_string($theme)) {
            $theme = Theme::load($theme);
        }

        return static::on($theme->getDirName());
    }
752891
public function setTheme($theme)
	{
	    $otheme = $this->options['theme'];
	    
		$this->options['theme'] = $theme;
		
		if ($otheme != $theme) {
		    $this->initViewConfig();
		}
		
		return $this;
	}
1175292
public static function list_templates($component, $search, $themename = '') {
        $params = self::validate_parameters(self::list_templates_parameters(),
                                            array(
                                                'component' => $component,
                                                'search' => $search,
                                                'themename' => $themename,
                                            ));

        return api::list_templates($component, $search, $themename);
    }
800947
public function set($theme, $group = null)
    {
        if (!is_null($group)) {
            $this->currentGroup = $group;
            $this->currentTheme[$group] = $theme;
        }

        if (is_null($this->currentGroup)) {
            throw new \Exception('Current group cannot be null. Use Theme::setCurrentGroup($group) or Theme::set($theme, $group)');
        }

        $this->currentTheme[$this->currentGroup] = $theme;

        return $this;
    }
1354499
public function find($theme)
	{
		foreach ($this->paths as $path)
		{
			if (is_dir($path.$theme))
			{
				return $path.$theme.DS;
			}
		}

		return false;
	}
1316139
public function findAndInstallThemes(): array
    {
        $theme = new Theme();
        $directories = $this->filesystem->directories($theme->getThemesDirectory());
        $themes = [];

        if (is_array($directories)) {
            foreach ($directories as $directory) {
                $themeName = basename($directory);
                $themes[] = new Theme($themeName);
            }
        }

        $this->cache->forever($this->cacheKey, $themes);

        return $themes;
    }