Files

37 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2026-10-05 18:10:18 -04:00
<?php
declare(strict_types=1);
namespace Pterodactyl\Console\Commands\Themes;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
2026-10-12 19:14:14 -04:00
use Pterodactyl\Services\Extensions\ExtensionRepository;
2026-10-12 07:47:42 -04:00
use Pterodactyl\Services\Themes\ThemeRepository;
2026-10-05 18:10:18 -04:00
2026-10-12 19:14:14 -04:00
#[Description('List the built-in and installed themes: which one is active, and which are enabled.')]
2026-10-05 18:10:18 -04:00
#[Signature('p:theme:list')]
class ListCommand extends Command
{
2026-10-12 19:14:14 -04:00
public function handle(ThemeRepository $themes, ExtensionRepository $extensions): int
2026-10-05 18:10:18 -04:00
{
2026-10-12 07:47:42 -04:00
$active = $themes->active();
2026-10-12 19:14:14 -04:00
$enabled = $extensions->configuredEnabled();
2026-10-12 07:47:42 -04:00
$rows = [[ThemeRepository::CLASSIC, 'Classic', '', $active === ThemeRepository::CLASSIC ? 'active' : 'built in']];
foreach ($themes->installed() as $theme) {
2026-10-12 19:14:14 -04:00
$state = match (true) {
$theme->id === $active => 'active',
$enabled->has($theme->id) => 'enabled',
default => 'disabled',
};
2026-10-12 07:47:42 -04:00
$problem = $themes->activationProblem($theme->id);
$rows[] = [$theme->id, $theme->name, $theme->theme?->extends, $problem === null ? $state : "{$state}, unusable: {$problem}"];
2026-10-05 18:10:18 -04:00
}
2026-10-12 07:47:42 -04:00
$this->table(['ID', 'Name', 'Extends', 'State'], $rows);
2026-10-05 18:10:18 -04:00
return self::SUCCESS;
}
}