@param string $themeName

@return Theme
320461
private function getTheme($themeName)
    {
        if (!array_key_exists($themeName, $this->themes)) {
            $this->themes[$themeName] = $this->themeManager->getTheme($themeName);
        }

        return $this->themes[$themeName];
    }
1139525
private function getThemeDirs(ContainerBuilder $container, array $themeList): array
    {
        $paths = array_map(
            static function (array $bundleMetadata): string {
                return $bundleMetadata['path'] . '/Resources/views/ngbm/themes';
            },
            // Reversing the list of bundles so bundles added at end have higher priority
            // when searching for a template
            array_reverse($container->getParameter('kernel.bundles_metadata'))
        );

        $paths = array_values(array_filter($paths, 'is_dir'));

        if ($container->hasParameter('twig.default_path')) {
            $defaultTwigDir = $container->getParameterBag()->resolveValue($container->getParameter('twig.default_path')) . '/ngbm/themes';
            if (is_dir($defaultTwigDir)) {
                array_unshift($paths, $defaultTwigDir);
            }
        }

        $appDir = $this->getAppDir($container) . '/Resources/views/ngbm/themes';
        if (is_dir($appDir)) {
            array_unshift($paths, $appDir);
        }

        $themeDirs = [];
        foreach ($paths as $path) {
            foreach ($themeList as $themeName) {
                $themeDirs[$themeName][] = $path . '/' . $themeName;
            }
        }

        return $themeDirs;
    }
844731
protected function getBasePath(Theme $theme = null) : string
    {
        $theme = $theme ?? $this->getTheme();

        if (isset($this->fullPaths[$theme->getKey()])) {
            return $this->fullPaths[$theme->getKey()];
        }

        return $this->fullPaths[$theme->getKey()] = $this->createPath($theme->getPath(), $this->directory);
    }
600143
protected function getThemes(string $theme)
    {
        try {
            return $this->themes->get($theme, false);
        } catch (\InvalidArgumentException $e) {
            throw new \InvalidArgumentException('Theme \'' . $theme . '\' not found');
        }
    }
825890
public function generateSlots($dir, $themeName, $templateName, array $slots)
    {
        $themeBasename = str_replace('Bundle', '', $themeName);
        $extensionAlias = Container::underscore($themeBasename);

        $parameters = array(
            'theme_name' => $extensionAlias,
            'template_name' => $templateName,
            "slots" => $slots,
        );

        $slotFile = $templateName . '.xml';
        $this->setSkeletonDirs($this->themeSkeletonDir);
        $this->renderFile('slots.xml', $dir . '/' . $slotFile, $parameters);

        $message = '';
        foreach ($slots as $slotName => $slot) {
            if (array_key_exists('errors', $slot)) {
                foreach ($slot['errors'] as $error) {
                    $message .= sprintf('<error>The argument %s assigned to the %s slot is not recognized</error>', $error, $slotName);
                }
            }
        }
        $message .= sprintf('The template\'s slots <info>%s</info> has been generated into <info>%s</info>', $slotFile, $dir);

        return $message;
    }
1246402
public function setOverride($theme = null) : ?Theme
    {
        if ($theme === null) {
            return $this->override = null;
        }

        if ($theme instanceof Theme) {
            $this->override = $theme;
        } elseif ($this->has($theme)) {
            $this->override = $this->get($theme);
        }

        if ($this->override === null || ($this->override !== null && !$this->override->verified())) {
            $this->override = $this->default;
        }

        return $this->override;
    }
127116
public function getThemeBootstrapVersion($themeName = null)
    {
        if (null === $themeName) {
            if (null !== $this->bootstrapVersion) {
                return $this->bootstrapVersion;
            }

            $themeName = $this->getActiveThemeBackend()->getThemeName();
        }

        $this->bootstrapVersion = $this->container->getParameter('red_kite_cms.bootstrap_version');

        if ( ! $this->container->hasParameter('red_kite_labs_theme_engine.bootstrap_themes')) {
            return $this->bootstrapVersion;
        }

        $themes = $this->container->getParameter('red_kite_labs_theme_engine.bootstrap_themes');
        if (array_key_exists($themeName, $themes)) {
            $this->bootstrapVersion = $themes[$themeName];
        }

        return $this->bootstrapVersion;
    }
90903
public static function convertFromLegacyTheme($theme)
    {
        if ($theme instanceof ConfigurablePlatformTheme) {
            return $theme;
        }

        // older themes are stored as an instance, newer ones as array
        if(is_array($theme)) {
            if(empty($theme[ThemeServiceInterface::THEME_CLASS_OFFSET])) {
                throw new \common_exception_MissingParameter(
                    ThemeServiceInterface::THEME_CLASS_OFFSET,
                    __METHOD__
                );
            }

            $options = !empty($theme[ThemeServiceInterface::THEME_OPTIONS_OFFSET])
                ? $theme[ThemeServiceInterface::THEME_OPTIONS_OFFSET]
                : []
            ;

            $theme = new $theme[ThemeServiceInterface::THEME_CLASS_OFFSET]($options);
        }

        // list of all previously used templates
        $templates = ['footer', 'header', 'header-logo', 'login-message'];

        // all keys associated with a public getter from previously used theme classes
        $getKeys = ['id', 'label', 'stylesheet', 'logoUrl', 'link', 'message', 'customTexts'];

        // collect options
        $options = [];
        if (method_exists($theme, 'getOptions')) {
            $options = $theme->getOptions();
        }

        if (method_exists($theme, 'getThemeData')) {
            $options = array_merge($options, $theme->getThemeData());
        }
        unset($options['data']);

        foreach ($getKeys as $key) {
            $method = 'get' . ucfirst($key);
            if (method_exists($theme, $method)) {
                $options[$key] = $theme->{$method}();
            }
        }
        // TAO default logo URL is different
        if($theme instanceof DefaultTheme) {
            $options['logoUrl'] = Template::img('tao-logo.png', 'tao');
        }

        if (method_exists($theme, 'getTemplate')) {
            if (empty($options[ConfigurablePlatformTheme::TEMPLATES])) {
                $options[ConfigurablePlatformTheme::TEMPLATES] = [];
            }
            foreach ($templates as $id) {
                $template = $theme->getTemplate($id);
                if(!is_null($template)) {
                    $options[ConfigurablePlatformTheme::TEMPLATES][$id] = $template;
                }
            }
        }

        // example: oat\taoExtension\model\theme\MyTheme
        $themeClass = get_class($theme);
        //@todo: map to container id
        if (empty($options[ConfigurablePlatformTheme::EXTENSION_ID])) {
            strtok($themeClass, '\\');
            $options[ConfigurablePlatformTheme::EXTENSION_ID] = strtok('\\');
        }

        if (empty($options[ConfigurablePlatformTheme::LABEL])) {
            $options[ConfigurablePlatformTheme::LABEL] = basename($themeClass);
        }
        return new ConfigurablePlatformTheme($options);
    }
1071535
public static function forTheme($theme)
    {
        $dirName = $theme->getDirName();
        if ($themeData = array_get(self::$instances, $dirName)) {
            return $themeData;
        }

        try {
            $themeData = self::firstOrCreate(['theme' => $dirName]);
        }
        catch (Exception $ex) {
            // Database failed
            $themeData = new self(['theme' => $dirName]);
        }

        return self::$instances[$dirName] = $themeData;
    }
854589
public function getTheme($themeName)
    {
        if (empty($themeName)) {
            throw new \InvalidArgumentException('The theme name must not be empty.');
        } elseif (!$this->hasTheme($themeName)) {
            throw new \LogicException(sprintf('Unable to retrieve definition for theme "%s".', $themeName));
        }

        if (!isset($this->instances[$themeName])) {
            $theme = $this->themeFactory->create($themeName, $this->themeDefinitions[$themeName]);
            $this->instances[$themeName] = $this->mergePageTemplates($theme);
        }

        return $this->instances[$themeName];
    }
23978
public function theme($theme = null)
    {
        if ($theme === null) {
            return $this->_theme;
        }
        $this->_theme = $theme;

        return $this;
    }
214661
public function setHost(string $hostname)
    {
        if (($ppos = strrpos($hostname, ":")) !== false)
        {
            $this->port = substr($hostname, $ppos + 1);
            $hostname = substr($hostname, 0, $ppos);
        }

        if (substr($hostname, 0, 4) === "xn--")
            $hostname = \idn_to_utf8($hostname);

        $this->host = strtolower($hostname);
        return $this;
    }
4542
protected function setProvider($name, ThemeProviderInterface $provider) {
        $k = ObjectHelper::getShortName($name);
        $v = $this->getIndex()[$k];
        if (null !== $v) {
            $this->getProviders()[$v] = $provider;
            return $this;
        }
        $this->index[$k] = count($this->getProviders());
        return $this->addProvider($provider);
    }
1172325
public function showPage($pageName = 'index')
    {
        if (!$this->page->exists($pageName)) {
            return \Response::view($this->theme.'.404', array('global' => $this->global), 404);
        }

        $page = $this->page->get($pageName);

        $viewParamaters = array(
            'global' => $this->global,
            'page' => $page
        );

        if (\View::exists($this->theme.'.'.$pageName)) {
            return \View::make($this->theme.'.'.$pageName, $viewParamaters);
        } else {
            return \View::make($this->theme.'.page', $viewParamaters);
        }
    }
639995
public function themeOption($name)
    {
        return isset($this->themeOptions[$name]) ? $this->themeOptions[$name] : null;
    }
1314282
protected function getThemes(?string $theme)
    {
        if ($theme === null || $theme === 'all') {
            return $this->themes->all();
        }

        try {
            return $this->themes->get($theme, false);
        } catch (\InvalidArgumentException $e) {
            throw new \InvalidArgumentException('Theme ' . $theme . ' not found');
        }
    }
593596
public function getBackgroundColorEscapeSequence ( $colorName = '' ) {
        if ( $this->_isDefinedColor($colorName) === true ) {
            $colors = self::getDefinedColors();
            list($textColor, $backgroundColor) = $colors[$colorName];
            return $backgroundColor;
        }
        return '';
    }