Prepare theme arrays: available, unavailable, uninstalled.

@param array $themes
Themes passed from a user.
193457
protected function prepareThemesArrays($themes)
    {
        $siteThemes = $this->getThemes();
        foreach ($themes as $themeName) {
            if (isset($siteThemes[$themeName]) && $siteThemes[$themeName]->status == 1) {
                $this->addAvailableTheme($themeName, $siteThemes[$themeName]->info['name']);
            } elseif (isset($siteThemes[$themeName]) && $siteThemes[$themeName]->status == 0) {
                $this->addUninstalledTheme($themeName, $siteThemes[$themeName]->info['name']);
            } else {
                $this->addUnavailableTheme($themeName, $themeName);
            }
        }
    }
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];
    }
1094880
public function setArrays(array $arrays)
    {
        $this->data = (isset($arrays[0]) && is_array($arrays[0])) ?
            $arrays :
            [$arrays];
    }
1027667
function(name, theme) {
	        name != null && theme != null && (App.settings.themes[name] = theme);
	        delete App.vars.cache.themeKeys;
	        return this;
	    }
543297
protected function clearCompiled(array $themes)
    {
        foreach ($themes as $theme) {
            $this->warn('Clearing files for `' . $theme->getKey() . '`');
            $this->info('Clearing styles...');
            $this->clearCompiledFiles($this->styles->getResourcePath('compiled_*.css', $theme));

            $this->info('Clearing scripts...');
            $this->clearCompiledFiles($this->scripts->getResourcePath('compiled_*.js', $theme));

            $this->warn('Done!');
            $this->line('');
        }
    }
1216106
protected function loadViewsFromTheme(Theme $theme)
    {
        $views = $theme->getViewDirectory();

        $this->loadViewsFrom($views, $theme->getName());
        $this->loadViewsFrom($views.'/boomcms', 'boomcms');
        $this->loadViewsFrom($views.'/chunks', 'boomcms.chunks');
    }
282728
public function rebuild(array $themes, $cache = true)
    {
        $logs = [];

        foreach ($themes as $theme) {
            $logs[$theme->getNormalizedName()] = $this->rebuildTheme($theme, $cache);
        }

        return $logs;
    }
44787
public function setTheme($theme, array $mods = [], array $options = [], array $menus = [], array $sidebars = [])
    {
        $this->setOptions($options);
        switch_theme($theme);
        $this->setThemeMods($mods);
        $this->createMenus($menus);
        $this->setupSidebars($sidebars);
    }
686879
public function delete(Theme $theme, User $user, $skipErrors = false)
    {
        if (!$this->canEdit($theme, $user)) {
            if (!$skipErrors) {
                throw new \Exception('You can not delete this theme.');
            } else {
                return;
            }
        }

        $this->om->remove($theme);
        $this->om->flush();

        // todo : to remove and delete src-files instead
        $fs = new Filesystem();
        $fs->remove("{$this->themeDir}/{$theme->getNormalizedName()}");
    }
1115904
public function setTheme(string $theme): FieldTypeInterface
    {
        $this->options['theme'] = $theme;

        // Update all attached fields with the given theme.
        foreach ($this->repository->all() as $field) {
            /** @var FieldTypeInterface $field */
            $field->setTheme($theme);
        }

        // Update all attached groups with the given theme.
        foreach ($this->repository()->getGroups() as $group) {
            /** @var SectionInterface $group */
            $group->setTheme($theme);
        }

        return $this;
    }
1117940
public function update(Theme &$theme)
    {
        $data = $theme->exportData();
        $endpoint = '/admin/themes/'.$theme->id.'.json';
        $response = $this->request(
            $endpoint, 'PUT', array(
            'theme' => $data
            )
        );
        $theme->setData($response['theme']);
    }
465774
public function deleteMulti(array $keys): void
    {
        if ($this->enabled === false) {
            return;
        }

        foreach ($keys as $index) {
            if ($key = $this->cacheIndex[$index] ?? null) {
                unset($this->cacheIndex[$index]);
            } else {
                $key = $index;
            }

            unset($this->cache[$key], $this->cacheExpiryTime[$key], $this->cacheAccessCount[$key]);
        }
    }
458324
public function setTheme($theme)
    {
        if($this->theme instanceof Theme) {
            $this->assets->removeFilePath($this->theme->getRealPath());
        }

        if (is_bool($theme)) {
            $this->theme = false;
        } elseif(($moduleTheme = modules()->top()->getTheme($theme, true)) instanceof Theme) {
            $this->theme = $moduleTheme;
        } elseif(($appTheme = modules()->first()->getTheme($theme, true)) instanceof Theme) {
            $this->theme = $appTheme;
        }

        if($this->theme) {
            if ( ! defined('PATH_THEME')) {
                define('PATH_THEME', $this->theme->getRealPath());
            }

            // add theme assets directory
            $this->assets->pushFilePath($this->theme->getRealPath());

            if(is_dir($themeViewPath = $this->theme->getRealPath() . 'views' . DIRECTORY_SEPARATOR)) {

                // add theme view directory
                view()->addFilePath($this->theme->getRealPath());

                // add theme output directory
                output()->pushFilePath($themeViewPath);

                $modules = modules()->getArrayCopy();

                foreach($modules as $module) {
                    if ( ! in_array($module->getType(), ['KERNEL', 'FRAMEWORK', 'APP'])) {
                        $moduleResourcesPath = str_replace(PATH_RESOURCES, '', $module->getResourcesDir());

                        if(is_dir($themeViewPath . $moduleResourcesPath)) {
                            view()->pushFilePath($themeViewPath . $moduleResourcesPath);
                        }
                    }
                }
            }
        }
        
        return $this;
    }
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;
    }
1074043
protected function set_theme($theme = null, $type = 'active')
	{
		// set the theme if given
		if ($theme !== null)
		{
			// remove the defined theme asset paths from the asset instance
			empty($this->active['asset_path']) or $this->asset->remove_path($this->active['asset_path']);
			empty($this->fallback['asset_path']) or $this->asset->remove_path($this->fallback['asset_path']);

			$this->{$type} = $this->create_theme_array($theme);

			// add the asset paths to the asset instance
			empty($this->fallback['asset_path']) or $this->asset->add_path($this->fallback['asset_path']);
			empty($this->active['asset_path']) or $this->asset->add_path($this->active['asset_path']);
		}

		// and return the theme config
		return $this->{$type};
	}
791324
protected function addThemes(Theme $theme, $config)
    {
        if (!is_array($config) && !($config instanceof \Traversable)) {
            return $this;
        }

        foreach ($config as $name => $conf) {
            if (!isset($conf['path'])) {
                continue;
            }

            $theme->addLocation($name, $conf['path']);
        }

        return $this;
    }
760733
public function reload_theme() {
        if (!is_null($this->_theme)) {
            $this->_theme = theme_config::load($this->_theme->name);
        }
    }