|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the SexyField package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Dion Snoeijen <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare (strict_types = 1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Tardigrades\Command; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Command\Command; |
|
17
|
|
|
use Symfony\Component\Console\Helper\Table; |
|
18
|
|
|
use Symfony\Component\Console\Helper\TableCell; |
|
19
|
|
|
use Symfony\Component\Console\Helper\TableSeparator; |
|
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
21
|
|
|
use Tardigrades\Entity\Application; |
|
22
|
|
|
use Tardigrades\Entity\Language; |
|
23
|
|
|
use Tardigrades\Entity\Section; |
|
24
|
|
|
|
|
25
|
|
|
abstract class ApplicationCommand extends Command |
|
26
|
|
|
{ |
|
27
|
|
|
protected function renderTable(OutputInterface $output, array $applications, string $info): void |
|
28
|
|
|
{ |
|
29
|
|
|
$table = new Table($output); |
|
30
|
|
|
|
|
31
|
|
|
$rows = []; |
|
32
|
|
|
/** @var Application $application */ |
|
33
|
|
|
foreach ($applications as $application) { |
|
34
|
|
|
$sections = $application->getSections(); |
|
35
|
|
|
$sectionsText = ''; |
|
36
|
|
|
/** @var Section $section */ |
|
37
|
|
|
foreach ($sections as $section) { |
|
38
|
|
|
$sectionsText .= $section->getName() . "\n"; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$languages = $application->getLanguages(); |
|
42
|
|
|
$languageText = ''; |
|
43
|
|
|
/** @var Language $language */ |
|
44
|
|
|
foreach ($languages as $language) { |
|
45
|
|
|
$languageText .= (string) $language->getI18n() . "\n"; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$rows[] = [ |
|
49
|
|
|
$application->getId(), |
|
50
|
|
|
$application->getName(), |
|
51
|
|
|
$application->getHandle(), |
|
52
|
|
|
$sectionsText, |
|
53
|
|
|
$languageText, |
|
54
|
|
|
$application->getCreated()->format('D-m-y'), |
|
55
|
|
|
$application->getUpdated()->format('D-m-y') |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$rows[] = new TableSeparator(); |
|
60
|
|
|
$rows[] = [ |
|
61
|
|
|
new TableCell('<info>' . $info . '</info>', ['colspan' => 6]) |
|
62
|
|
|
]; |
|
63
|
|
|
|
|
64
|
|
|
$table |
|
65
|
|
|
->setHeaders(['#id', 'name', 'handle', 'sections', 'languages', 'created', 'updated']) |
|
66
|
|
|
->setRows($rows) |
|
67
|
|
|
; |
|
68
|
|
|
$table->render(); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|