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
|
|
|
|
24
|
|
|
abstract class LanguageCommand extends Command |
25
|
|
|
{ |
26
|
|
|
protected function renderTable(OutputInterface $output, array $languages, string $info): void |
27
|
|
|
{ |
28
|
|
|
$table = new Table($output); |
29
|
|
|
|
30
|
|
|
$rows = []; |
31
|
|
|
/** @var Language $language */ |
32
|
|
|
foreach ($languages as $language) { |
33
|
|
|
$applications = $language->getApplications(); |
34
|
|
|
$applicationText = ''; |
35
|
|
|
/** @var Application $application */ |
36
|
|
|
foreach ($applications as $application) { |
37
|
|
|
$applicationText .= $application->getName() . "\n"; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$rows[] = [ |
41
|
|
|
$language->getId(), |
42
|
|
|
(string) $language->getI18n(), |
43
|
|
|
$applicationText, |
44
|
|
|
$language->getCreated()->format('D-m-y'), |
45
|
|
|
$language->getUpdated()->format('D-m-y') |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$rows[] = new TableSeparator(); |
50
|
|
|
$rows[] = [ |
51
|
|
|
new TableCell('<info>' . $info . '</info>', ['colspan' => 6]) |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
$table |
55
|
|
|
->setHeaders(['#id', 'i18n', 'application', 'created', 'updated']) |
56
|
|
|
->setRows($rows) |
57
|
|
|
; |
58
|
|
|
$table->render(); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|