aboutsummaryrefslogtreecommitdiff
path: root/cli/Commands/Config/SectionList.php
blob: 28a0ed79ff85a715053c38b7b3c873bb23b8e19d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

namespace Studip\Cli\Commands\Config;

use ConfigurationModel;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class SectionList extends Command
{
    protected static $defaultName = 'config:section-list';

    protected function configure(): void
    {
        $this->setDescription('List all configuration sections');
        $this->setHelp('This command shows a list of available configuration sections.');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $ranges = ConfigurationModel::getConfig();
        $data = [];
        foreach (array_keys($ranges) as $range) {
            $data[] = [$range ?? _('Ohne Kategorie')];
        }
        $table  = new Table($output);
        $table->setHeaders(['Range'])
        ->setRows($data)
        ->setStyle('box')
        ->render();

        return Command::SUCCESS;
    }
}