blob: af4913d582f1e714b1b10aa08148bde90085afa0 (
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
37
38
39
|
<?php
namespace Studip\Cli\Commands\Cronjobs;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CronjobList extends Command
{
protected static $defaultName = 'cronjobs:list';
protected function configure(): void
{
$this->setDescription('List cronjobs.');
$this->setHelp('This command lists all available cronjobs.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$tasks = \CronjobTask::findBySql('1');
if ($tasks) {
$table = new Table($output);
$table->setStyle('compact');
$table->setHeaders(['Task-ID', 'Description']);
foreach ($tasks as $task) {
$description = call_user_func(['\\' . $task->class, 'getDescription']);
if ($description) {
$table->addRow([$task->id, $description]);
}
}
$table->render();
}
return Command::SUCCESS;
}
}
|