|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fab\Vidi\Command; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Fab/Vidi project under GPLv2 or later. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.md file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
14
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
15
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
16
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
17
|
|
|
use Symfony\Component\Console\Command\Command; |
|
18
|
|
|
use Fab\Vidi\Tca\Tca; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Command Controller which handles actions related to Vidi. |
|
22
|
|
|
*/ |
|
23
|
|
|
class VidiCommandController extends Command |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Configure the command by defining the name, options and arguments |
|
28
|
|
|
*/ |
|
29
|
|
|
protected function configure() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->setDescription('Check TCA configuration for relations used in grid.') |
|
32
|
|
|
->addOption( |
|
33
|
|
|
'table', |
|
34
|
|
|
'c', |
|
35
|
|
|
InputOption::VALUE_NONE, |
|
36
|
|
|
'The table name. If not defined check for every table.' |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Executes the command for removing the lock file |
|
42
|
|
|
* |
|
43
|
|
|
* @param InputInterface $input |
|
44
|
|
|
* @param OutputInterface $output |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
47
|
|
|
{ |
|
48
|
|
|
$io = new SymfonyStyle($input, $output); |
|
49
|
|
|
foreach ($GLOBALS['TCA'] as $tableName => $TCA) { |
|
50
|
|
|
$table = $input->getOption('table'); |
|
51
|
|
|
if ($table !== '' && $table !== $tableName) { |
|
52
|
|
|
continue; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$fields = Tca::grid($tableName)->getFields(); |
|
56
|
|
|
if (!empty($fields)) { |
|
57
|
|
|
|
|
58
|
|
|
$relations = $this->getGridAnalyserService()->checkRelationForTable($tableName); |
|
59
|
|
|
if (!empty($relations)) { |
|
60
|
|
|
|
|
61
|
|
|
$io->text(''); |
|
62
|
|
|
$io->text('--------------------------------------------------------------------'); |
|
63
|
|
|
$io->text(''); |
|
64
|
|
|
$io->text(sprintf('Relations for "%s"', $tableName)); |
|
65
|
|
|
$io->text(''); |
|
66
|
|
|
$io->text(implode("\n", $relations)); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get the Vidi Module Loader. |
|
74
|
|
|
* |
|
75
|
|
|
* @return \Fab\Vidi\Grid\GridAnalyserService|object |
|
76
|
|
|
*/ |
|
77
|
|
|
protected function getGridAnalyserService() |
|
78
|
|
|
{ |
|
79
|
|
|
return GeneralUtility::makeInstance(\Fab\Vidi\Grid\GridAnalyserService::class); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|