23
23
use Symfony \Component \Console \Input \InputOption ;
24
24
use Symfony \Component \Console \Output \OutputInterface ;
25
25
use TYPO3 \CMS \ContentBlocks \Generator \LanguageFileGenerator ;
26
+ use TYPO3 \CMS \ContentBlocks \Loader \ContentBlockLoader ;
26
27
use TYPO3 \CMS \ContentBlocks \Loader \LoadedContentBlock ;
27
28
use TYPO3 \CMS \ContentBlocks \Registry \ContentBlockRegistry ;
28
29
use TYPO3 \CMS \ContentBlocks \Utility \ContentBlockPathUtility ;
33
34
class GenerateLanguageFileCommand extends Command
34
35
{
35
36
public function __construct (
36
- protected readonly ContentBlockRegistry $ contentBlockRegistry ,
37
37
protected readonly LanguageFileGenerator $ languageFileGenerator ,
38
38
protected readonly PackageManager $ packageManager ,
39
+ protected readonly ContentBlockLoader $ contentBlockLoader ,
39
40
) {
40
41
parent ::__construct ();
41
42
}
@@ -63,6 +64,7 @@ protected function configure(): void
63
64
64
65
protected function execute (InputInterface $ input , OutputInterface $ output ): int
65
66
{
67
+ $ contentBlockRegistry = $ this ->contentBlockLoader ->loadUncached ();
66
68
$ contentBlockName = $ input ->getArgument ('content-block ' );
67
69
$ print = (bool )$ input ->getOption ('print ' );
68
70
$ extension = (string )$ input ->getOption ('extension ' );
@@ -81,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
81
83
}
82
84
83
85
if ($ print ) {
84
- $ this ->printLabelsXlf ($ contentBlockName , $ output );
86
+ $ this ->printLabelsXlf ($ contentBlockRegistry , $ contentBlockName , $ output );
85
87
} else {
86
88
if ($ extension !== '' ) {
87
89
try {
@@ -90,14 +92,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
90
92
$ output ->writeln ('<error>Extension with key " ' . $ extension . '" does not exist.</error> ' );
91
93
return Command::INVALID ;
92
94
}
93
- foreach ($ this -> contentBlockRegistry ->getAll () as $ contentBlock ) {
95
+ foreach ($ contentBlockRegistry ->getAll () as $ contentBlock ) {
94
96
if ($ contentBlock ->getHostExtension () !== $ extension ) {
95
97
continue ;
96
98
}
97
99
$ this ->writeLabelsXlf ($ contentBlock );
98
100
}
99
101
} else {
100
- $ contentBlock = $ this -> contentBlockRegistry ->getContentBlock ($ contentBlockName );
102
+ $ contentBlock = $ contentBlockRegistry ->getContentBlock ($ contentBlockName );
101
103
$ this ->writeLabelsXlf ($ contentBlock );
102
104
}
103
105
}
@@ -114,9 +116,9 @@ protected function writeLabelsXlf(LoadedContentBlock $contentBlock): void
114
116
GeneralUtility::writeFile ($ labelsXlfPath , $ result );
115
117
}
116
118
117
- protected function printLabelsXlf (string $ contentBlockName , OutputInterface $ output ): void
119
+ protected function printLabelsXlf (ContentBlockRegistry $ contentBlockRegistry , string $ contentBlockName , OutputInterface $ output ): void
118
120
{
119
- $ contentBlock = $ this -> contentBlockRegistry ->getContentBlock ($ contentBlockName );
121
+ $ contentBlock = $ contentBlockRegistry ->getContentBlock ($ contentBlockName );
120
122
$ result = $ this ->languageFileGenerator ->generate ($ contentBlock );
121
123
$ output ->writeln ($ result , OutputInterface::OUTPUT_RAW );
122
124
}
0 commit comments