Skip to content

Commit

Permalink
[TASK] Implement ContentBlocks cache
Browse files Browse the repository at this point in the history
The whole ContentBlockDefinitionCollection object is now
cached.
  • Loading branch information
nhovratov committed Feb 9, 2024
1 parent 9ac35a6 commit 8991e76
Show file tree
Hide file tree
Showing 16 changed files with 1,338 additions and 1,080 deletions.
12 changes: 6 additions & 6 deletions Classes/Builder/ContentBlockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
/**
* @internal Not part of TYPO3's public API.
*/
class ContentBlockBuilder
readonly class ContentBlockBuilder
{
public function __construct(
protected readonly HtmlTemplateCodeGenerator $htmlTemplateCodeGenerator,
protected readonly LanguageFileGenerator $languageFileGenerator,
protected readonly ContentBlockRegistry $contentBlockRegistry,
protected readonly TableDefinitionCollectionFactory $tableDefinitionCollectionFactory,
protected HtmlTemplateCodeGenerator $htmlTemplateCodeGenerator,
protected LanguageFileGenerator $languageFileGenerator,
protected ContentBlockRegistry $contentBlockRegistry,
protected TableDefinitionCollectionFactory $tableDefinitionCollectionFactory,
) {}

/**
Expand Down Expand Up @@ -80,7 +80,7 @@ public function create(LoadedContentBlock $contentBlock): void
protected function initializeRegistries(LoadedContentBlock $contentBlock): void
{
$this->contentBlockRegistry->register($contentBlock);
$tableDefinitionCollection = $this->tableDefinitionCollectionFactory->createUncached();
$tableDefinitionCollection = $this->tableDefinitionCollectionFactory->createUncached($this->contentBlockRegistry);
$automaticLanguageKeysRegistry = $tableDefinitionCollection->getAutomaticLanguageKeysRegistry();
$this->languageFileGenerator->setAutomaticLanguageKeysRegistry($automaticLanguageKeysRegistry);
}
Expand Down
47 changes: 47 additions & 0 deletions Classes/Definition/Factory/CompilationResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace TYPO3\CMS\ContentBlocks\Definition\Factory;

use TYPO3\CMS\ContentBlocks\Registry\AutomaticLanguageKeysRegistry;

final class CompilationResult
{
public function __construct(
private readonly AutomaticLanguageKeysRegistry $automaticLanguageKeys,
/**
* @var array<string, array>
*/
private readonly array $parentReferences,
private readonly array $mergedTableDefinitions,
) {}

public function getAutomaticLanguageKeys(): AutomaticLanguageKeysRegistry
{
return $this->automaticLanguageKeys;
}

public function getParentReferences(): array
{
return $this->parentReferences;
}

public function getMergedTableDefinitions(): array
{
return $this->mergedTableDefinitions;
}
}
Loading

0 comments on commit 8991e76

Please sign in to comment.