|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Spiral\Command\Tokenizer; |
|
6
|
|
|
|
|
7
|
|
|
use Spiral\Boot\DirectoriesInterface; |
|
8
|
|
|
use Spiral\Console\Command; |
|
9
|
|
|
use Spiral\Tokenizer\Config\TokenizerConfig; |
|
10
|
|
|
|
|
11
|
|
|
final class InfoCommand extends Command |
|
12
|
|
|
{ |
|
13
|
|
|
protected const NAME = 'tokenizer:info'; |
|
14
|
|
|
protected const DESCRIPTION = 'Get information about tokenizer directories to scan'; |
|
15
|
|
|
|
|
16
|
|
|
public function perform(TokenizerConfig $config, DirectoriesInterface $dirs): int |
|
17
|
|
|
{ |
|
18
|
|
|
$this->info('Included directories:'); |
|
19
|
|
|
$grid = $this->table(['Directory', 'Scope']); |
|
20
|
|
|
foreach ($config->getDirectories() as $directory) { |
|
21
|
|
|
$grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']); |
|
22
|
|
|
} |
|
23
|
|
|
foreach ($config->getScopes() as $scope => $data) { |
|
24
|
|
|
foreach ($data['directories'] ?? [] as $directory) { |
|
25
|
|
|
$grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]); |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
$grid->render(); |
|
30
|
|
|
|
|
31
|
|
|
$this->newLine(); |
|
32
|
|
|
|
|
33
|
|
|
$this->info('Excluded directories:'); |
|
34
|
|
|
$grid = $this->table(['Directory', 'Scope']); |
|
35
|
|
|
foreach ($config->getExcludes() as $directory) { |
|
36
|
|
|
$grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']); |
|
37
|
|
|
} |
|
38
|
|
|
foreach ($config->getScopes() as $scope => $data) { |
|
39
|
|
|
foreach ($data['exclude'] ?? [] as $directory) { |
|
40
|
|
|
$grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$grid->render(); |
|
45
|
|
|
|
|
46
|
|
|
$this->newLine(); |
|
47
|
|
|
|
|
48
|
|
|
$this->info('Loaders:'); |
|
49
|
|
|
$grid = $this->table(['Loader', 'Status']); |
|
50
|
|
|
|
|
51
|
|
|
$grid->addRow(['Classes', $config->isLoadClassesEnabled() |
|
52
|
|
|
? '<info>enabled</>' |
|
53
|
|
|
: '<error>disabled</>. <comment>To enable, add "TOKENIZER_LOAD_CLASSES=true" to your .env file.</>']); |
|
54
|
|
|
$grid->addRow(['Enums', $config->isLoadEnumsEnabled() |
|
55
|
|
|
? '<info>enabled</>' |
|
56
|
|
|
: '<error>disabled</>. <comment>To enable, add "TOKENIZER_LOAD_ENUMS=true" to your .env file.</>']); |
|
57
|
|
|
$grid->addRow( |
|
58
|
|
|
['Interfaces', $config->isLoadInterfacesEnabled() |
|
59
|
|
|
? '<info>enabled</>' |
|
60
|
|
|
: '<error>disabled</>. <comment>To enable, add "TOKENIZER_LOAD_INTERFACES=true" to your .env file.</>'] |
|
61
|
|
|
); |
|
62
|
|
|
|
|
63
|
|
|
$grid->render(); |
|
64
|
|
|
|
|
65
|
|
|
$this->newLine(); |
|
66
|
|
|
$this->info( |
|
67
|
|
|
\sprintf('Tokenizer cache: %s', $config->isCacheEnabled() ? '<info>enabled</>' : '<error>disabled</>'), |
|
68
|
|
|
); |
|
69
|
|
|
if (!$config->isCacheEnabled()) { |
|
70
|
|
|
$this->comment('To enable cache, add "TOKENIZER_CACHE_TARGETS=true" to your .env file.'); |
|
71
|
|
|
$this->comment('Read more at https://spiral.dev/docs/advanced-tokenizer/#class-listeners'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
return self::SUCCESS; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|