winter/modules/system/console/ThemeList.php

69 lines
1.9 KiB
PHP
Raw Normal View History

<?php namespace System\Console;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Cms\Classes\Theme;
use Cms\Classes\ThemeManager;
use System\Classes\UpdateManager;
/**
* Console command to list themes.
*
* This lists all the available themes in the system. It also shows the active theme.
*
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class ThemeList extends Command
{
/**
* The console command name.
*/
protected $name = 'theme:list';
/**
* The console command description.
*/
protected $description = 'List available themes.';
/**
* Execute the console command.
*/
2017-07-14 16:28:47 +10:00
public function handle()
{
2015-05-02 12:29:22 +10:00
$themeManager = ThemeManager::instance();
$updateManager = UpdateManager::instance();
foreach (Theme::all() as $theme) {
$flag = $theme->isActiveTheme() ? '[*] ' : '[-] ';
$themeId = $theme->getId();
$themeName = $themeManager->findByDirName($themeId) ?: $themeId;
$this->info($flag . $themeName);
}
if ($this->option('include-marketplace')) {
// @todo List everything in the marketplace - not just popular.
2015-05-02 12:29:22 +10:00
$popularThemes = $updateManager->requestPopularProducts('theme');
2015-05-02 12:29:22 +10:00
foreach ($popularThemes as $popularTheme) {
if (!$themeManager->isInstalled($popularTheme['code'])) {
$this->info('[ ] '.$popularTheme['code']);
}
}
}
2015-05-02 12:29:22 +10:00
$this->info(PHP_EOL."[*] Active [-] Installed [ ] Not installed");
}
/**
* Get the console command options.
*/
protected function getOptions()
{
return [
2015-04-26 20:16:38 +02:00
['include-marketplace', 'm', InputOption::VALUE_NONE, 'Include downloadable themes from the October marketplace.']
];
}
}