@param array $existThemePaths
@param array $themes

@return array
496680
private function filterThemeLayoutUpdates(array $existThemePaths, array $themes)
    {
        foreach ($themes as $theme => $themePaths) {
            foreach ($themePaths as $pathIndex => $path) {
                if (is_string($path) && isset($existThemePaths[$path])) {
                    unset($themePaths[$pathIndex]);
                }
            }
            if (empty($themePaths)) {
                unset($themes[$theme]);
            } else {
                $themes[$theme] = $themePaths;
            }
        }

        return $themes;
    }
243796
private function getTheme($target, $themeId){

        $returnValue = null;
        if(!$this->isRegistered($target)){
            throw new \common_Exception('Target '.$target.' does not exist');
        } else {
            $array = $this->get($target);
            $found = false;
            foreach ($array['available'] as $theme) {
                if ($theme['id'] == $themeId) {
                    $found = true;
                    $returnValue = $theme;
                    break;
                }
            }
            if (!$found) {
                throw new ThemeNotFoundException('Theme '.$themeId.' not found for target '.$target);
            }
        }
        return $returnValue;
    }
823111
private function hydrateThemes(array $configurations, array $themes)
    {
        foreach ($configurations as $configuration) {
            $themeName = $configuration['name'];

            $configuration['parents'] = $this->convertParentsNamesToParentsObjects($themeName, $configuration['parents'], $themes);
            $configuration['authors'] = $this->convertAuthorsArraysToAuthorsObjects($configuration['authors']);
            $configuration['screenshots'] = $this->convertScreenshotsArraysToScreenshotsObjects($configuration['screenshots']);

            $themes[$themeName] = $this->themeHydrator->hydrate($configuration, $themes[$themeName]);
        }

        return $themes;
    }
119442
public function getTheme($theme, $failover = true)
    {
        $theme = dash($theme);

        if ($failover === false) {
            if (is_dir($themePath = $this->getResourcesDir('themes') . $theme . DIRECTORY_SEPARATOR)) {
                $themeObject = new Module\Theme($themePath);

                if ($themeObject->isValid()) {
                    return $themeObject;
                }
            }
        } else {
            foreach (modules() as $module) {
                if (in_array($module->getType(), ['KERNEL', 'FRAMEWORK'])) {
                    continue;
                } elseif ($themeObject = $module->getTheme($theme, false)) {
                    return $themeObject;
                }
            }
        }

        return false;
    }
493122
public function allowedThemes()
    {
        if ($themes = self::$allowed_themes) {
            return ArrayLib::valuekey($themes);
        }

        $themes = [];
        if (is_dir(THEMES_PATH)) {
            foreach (scandir(THEMES_PATH) as $theme) {
                if ($theme[0] == '.') {
                    continue;
                }
                $theme = strtok($theme, '_');
                $themes[$theme] = $theme;
            }
            ksort($themes);
        }
        return $themes;
    }
480382
private function hydrateThemes(array $configurations, array $themes): array
    {
        foreach ($configurations as $configuration) {
            $themeName = $configuration['name'];

            $configuration['parents'] = $this->convertParentsNamesToParentsObjects($themeName, $configuration['parents'], $themes);
            $configuration['authors'] = $this->convertAuthorsArraysToAuthorsObjects($configuration['authors']);
            $configuration['screenshots'] = $this->convertScreenshotsArraysToScreenshotsObjects($configuration['screenshots']);

            /** @var ThemeInterface $theme */
            $theme = $this->themeHydrator->hydrate($configuration, $themes[$themeName]);

            Assert::isInstanceOf($theme, ThemeInterface::class);

            $themes[$themeName] = $theme;
        }

        return $themes;
    }
922208
protected function copyContentFromThemeToSite($sitePath, $relativeThemePath)
    {
        if ($this->fs->exists($sitePath.'/'.$relativeThemePath) === false) {
            throw new \RuntimeException('The theme has not been installed correctly.');
        }

        $finder = new Finder();
        $finder->in($sitePath.'/'.$relativeThemePath.'/src/content')
            ->exclude(['assets'])
            ->files();

        foreach ($finder as $file) {
            $this->fs->copy($file->getRealpath(), $sitePath.'/src/content/'.$file->getRelativePathname(), true);
        }
    }
1262961
public function absolutePath($theme = null)
    {
        if (is_null($theme)) {
            $theme = $this->getCurrent();
        }

        return $this->config['paths']['absolute'].'/'.$theme;
    }
430402
public function getThemeResourceUrl(string $resource, Theme $theme = null) : string
    {
        return $this->createPath($this->getThemeBaseUrl($theme), $resource);
    }
1249770
protected function prepare_ignored_themes( array $themes ) {
		$valid_slugs = array_values( wp_list_pluck(
			wp_get_themes(),
			'stylesheet'
		) );

		return array_values( array_intersect( $valid_slugs, $themes ) );
	}
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;
    }
980356
def list_themes(cls, path=THEMES):
        
        themes, errors = [], OrderedDict()

        def load_themes(path, source):
            """
            Load all themes in the given path.
            """
            if os.path.isdir(path):
                for filename in sorted(os.listdir(path)):
                    if not filename.endswith('.cfg'):
                        continue

                    filepath = os.path.join(path, filename)
                    name = filename[:-4]
                    try:
                        # Make sure the theme is valid
                        theme = cls.from_file(filepath, source)
                    except Exception as e:
                        errors[(source, name)] = e
                    else:
                        themes.append(theme)

        themes.extend([Theme(use_color=True), Theme(use_color=False)])
        load_themes(DEFAULT_THEMES, 'preset')
        load_themes(path, 'installed')

        return themes, errors
1200788
public function add(array $themes) {

        foreach($themes as $themeId => $label) {
            $prefixedId =  $this->getPrefixedThemeId($themeId);
            if($this->themeExists($prefixedId)) {
                continue;
            }
            $this->register($themeId, $label);
        }

        $this->logInfo('Item themes registered: ' . implode(',', array_keys($themes)));
        return true;
    }
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;
    }
600143
protected function getThemes(string $theme)
    {
        try {
            return $this->themes->get($theme, false);
        } catch (\InvalidArgumentException $e) {
            throw new \InvalidArgumentException('Theme \'' . $theme . '\' not found');
        }
    }
251971
public function findOrFail($theme, $type = 'frontend')
    {
        if (in_array($type . '.' . $theme, array_keys($this->themes))) {
            return $this->themes[$type . '.' . $theme];
        }

        throw new ThemeNotFoundException('Theme not found!');
    }
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');
        }
    }