Skip to content

Commit c3156cf

Browse files
committed
[TASK] Un-cached GenerateLanguageFileCommand
1 parent 526a3d2 commit c3156cf

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Classes/Command/GenerateLanguageFileCommand.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\Console\Input\InputOption;
2424
use Symfony\Component\Console\Output\OutputInterface;
2525
use TYPO3\CMS\ContentBlocks\Generator\LanguageFileGenerator;
26+
use TYPO3\CMS\ContentBlocks\Loader\ContentBlockLoader;
2627
use TYPO3\CMS\ContentBlocks\Loader\LoadedContentBlock;
2728
use TYPO3\CMS\ContentBlocks\Registry\ContentBlockRegistry;
2829
use TYPO3\CMS\ContentBlocks\Utility\ContentBlockPathUtility;
@@ -33,9 +34,9 @@
3334
class GenerateLanguageFileCommand extends Command
3435
{
3536
public function __construct(
36-
protected readonly ContentBlockRegistry $contentBlockRegistry,
3737
protected readonly LanguageFileGenerator $languageFileGenerator,
3838
protected readonly PackageManager $packageManager,
39+
protected readonly ContentBlockLoader $contentBlockLoader,
3940
) {
4041
parent::__construct();
4142
}
@@ -63,6 +64,7 @@ protected function configure(): void
6364

6465
protected function execute(InputInterface $input, OutputInterface $output): int
6566
{
67+
$contentBlockRegistry = $this->contentBlockLoader->loadUncached();
6668
$contentBlockName = $input->getArgument('content-block');
6769
$print = (bool)$input->getOption('print');
6870
$extension = (string)$input->getOption('extension');
@@ -81,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8183
}
8284

8385
if ($print) {
84-
$this->printLabelsXlf($contentBlockName, $output);
86+
$this->printLabelsXlf($contentBlockRegistry, $contentBlockName, $output);
8587
} else {
8688
if ($extension !== '') {
8789
try {
@@ -90,14 +92,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9092
$output->writeln('<error>Extension with key "' . $extension . '" does not exist.</error>');
9193
return Command::INVALID;
9294
}
93-
foreach ($this->contentBlockRegistry->getAll() as $contentBlock) {
95+
foreach ($contentBlockRegistry->getAll() as $contentBlock) {
9496
if ($contentBlock->getHostExtension() !== $extension) {
9597
continue;
9698
}
9799
$this->writeLabelsXlf($contentBlock);
98100
}
99101
} else {
100-
$contentBlock = $this->contentBlockRegistry->getContentBlock($contentBlockName);
102+
$contentBlock = $contentBlockRegistry->getContentBlock($contentBlockName);
101103
$this->writeLabelsXlf($contentBlock);
102104
}
103105
}
@@ -114,9 +116,9 @@ protected function writeLabelsXlf(LoadedContentBlock $contentBlock): void
114116
GeneralUtility::writeFile($labelsXlfPath, $result);
115117
}
116118

117-
protected function printLabelsXlf(string $contentBlockName, OutputInterface $output): void
119+
protected function printLabelsXlf(ContentBlockRegistry $contentBlockRegistry, string $contentBlockName, OutputInterface $output): void
118120
{
119-
$contentBlock = $this->contentBlockRegistry->getContentBlock($contentBlockName);
121+
$contentBlock = $contentBlockRegistry->getContentBlock($contentBlockName);
120122
$result = $this->languageFileGenerator->generate($contentBlock);
121123
$output->writeln($result, OutputInterface::OUTPUT_RAW);
122124
}

0 commit comments

Comments
 (0)