Skip to content

Commit

Permalink
[WIP][!!!][TASK] New Content Block folder structure
Browse files Browse the repository at this point in the history
todo:
- Migration wizard from old to new structure
- Documentation
  • Loading branch information
nhovratov committed Sep 16, 2024
1 parent 5d37c15 commit baafe73
Show file tree
Hide file tree
Showing 83 changed files with 223 additions and 226 deletions.
2 changes: 1 addition & 1 deletion Classes/Builder/ContentBlockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected function createEditorInterfaceYaml(LoadedContentBlock $contentBlock, s

protected function createLabelsXlf(LoadedContentBlock $contentBlock, string $basePath): void
{
GeneralUtility::mkdir_deep($basePath . '/' . ContentBlockPathUtility::getLanguageFolderPath());
GeneralUtility::mkdir_deep($basePath . '/' . ContentBlockPathUtility::getLanguageFolder());
$xliffContent = $this->languageFileGenerator->generate($contentBlock);
GeneralUtility::writeFile(
$basePath . '/' . ContentBlockPathUtility::getLanguageFilePath(),
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/GenerateLanguageFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
protected function writeLabelsXlf(LoadedContentBlock $contentBlock): void
{
$contentBlockPath = GeneralUtility::getFileAbsFileName($contentBlock->getExtPath());
$labelsFolder = $contentBlockPath . '/' . ContentBlockPathUtility::getLanguageFolderPath();
$labelsFolder = $contentBlockPath . '/' . ContentBlockPathUtility::getLanguageFolder();
$labelsXlfPath = $contentBlockPath . '/' . ContentBlockPathUtility::getLanguageFilePath();
$result = $this->languageFileGenerator->generate($contentBlock);
GeneralUtility::mkdir_deep($labelsFolder);
Expand Down
11 changes: 4 additions & 7 deletions Classes/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,16 @@ public static function getContentBlockTypoScript(ContainerInterface $container):
if ($tableDefinition->getContentType() === ContentType::CONTENT_ELEMENT) {
$extPath = $contentBlockRegistry->getContentBlockExtPath($typeDefinition->getName());
$privatePath = $extPath . '/' . ContentBlockPathUtility::getPrivateFolder();
$template = ContentBlockPathUtility::getFrontendTemplateFileNameWithoutExtension();
$template = ContentBlockPathUtility::getFrontendTemplateFileName();
$typoScript = <<<HEREDOC
tt_content.{$typeDefinition->getTypeName()} =< lib.contentBlock
tt_content.{$typeDefinition->getTypeName()} {
templateName = {$template}
templateRootPaths {
20 = $privatePath/
}
file = $privatePath/$template
partialRootPaths {
20 = $privatePath/Partials/
20 = $privatePath/partials/
}
layoutRootPaths {
20 = $privatePath/Layouts/
20 = $privatePath/layouts/
}
}
HEREDOC;
Expand Down
28 changes: 14 additions & 14 deletions Classes/Utility/ContentBlockPathUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public static function getContentBlockExtPath(string $extensionKey, string $cont

public static function getContentBlockDefinitionFileName(): string
{
return 'EditorInterface.yaml';
return 'config.yaml';
}

public static function getBackendPreviewFileName(): string
{
return 'EditorPreview.html';
return 'preview.html';
}

public static function getBackendPreviewFileNameWithoutExtension(): string
Expand All @@ -57,7 +57,7 @@ public static function getBackendPreviewPath(): string

public static function getFrontendTemplateFileName(): string
{
return 'Frontend.html';
return 'frontend.html';
}

public static function getFrontendTemplateFileNameWithoutExtension(): string
Expand All @@ -70,29 +70,24 @@ public static function getFrontendTemplatePath(): string
return self::getPrivateFolder() . '/' . self::getFrontendTemplateFileName();
}

public static function getLanguageFolderPath(): string
{
return self::getPrivateFolder() . '/Language';
}

public static function getLanguageFilePath(): string
{
return self::getLanguageFolderPath() . '/Labels.xlf';
return self::getLanguageFolder() . '/labels.xlf';
}

public static function getIconNameWithoutFileExtension(): string
{
return 'Icon';
return 'icon';
}

public static function getIconHideInMenuNameWithoutFileExtension(): string
{
return 'IconHideInMenu';
return 'icon-hide-in-menu';
}

public static function getIconRootNameWithoutFileExtension(): string
{
return 'IconRoot';
return 'icon-root';
}

public static function getIconPathWithoutFileExtension(): string
Expand Down Expand Up @@ -142,12 +137,17 @@ public static function getRecordTypesFolder(): string

public static function getPublicFolder(): string
{
return 'Assets';
return 'assets';
}

public static function getPrivateFolder(): string
{
return 'Source';
return 'templates';
}

public static function getLanguageFolder(): string
{
return 'language';
}

public static function getHostExtPublicContentBlockBasePath(string $hostExtension): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ <h1>{data.header}</h1>
<p>creationDate:{data.systemProperties.createdAt.timestamp}</p>
<p>updateDate:{data.systemProperties.lastUpdatedAt.timestamp}</p>
<span><f:translate key="{cb:languagePath()}:title"/></span>
<img src="{f:uri.resource(path: '{cb:assetPath()}/Icon.svg')}" alt="">
<img src="{f:uri.resource(path: '{cb:assetPath()}/Icon.svg', absolute: '1')}" alt="">
<img src="{f:uri.resource(path: '{cb:assetPath()}/icon.svg')}" alt="">
<img src="{f:uri.resource(path: '{cb:assetPath()}/icon.svg', absolute: '1')}" alt="">
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function variablesAndAssetsRendered(): void
// @todo The path should be absolute. See: https://github.com/TYPO3/testing-framework/issues/577
self::assertStringContainsString('<link href="typo3conf/ext/test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple/Frontend.css', $html);
self::assertStringContainsString('<script src="typo3conf/ext/test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple/Frontend.js', $html);
self::assertStringContainsString('<img src="typo3conf/ext/test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple/Icon.svg', $html);
self::assertStringContainsString('<img src="http://localhost/typo3conf/ext/test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple/Icon.svg', $html);
self::assertStringContainsString('<img src="typo3conf/ext/test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple/icon.svg', $html);
self::assertStringContainsString('<img src="http://localhost/typo3conf/ext/test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple/icon.svg', $html);
}

#[Test]
Expand Down
6 changes: 3 additions & 3 deletions Tests/Functional/Generator/IconGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function registeredContentBlockIconsHaveCorrectConfigurationDataPr
[
'provider' => SvgIconProvider::class,
'options' => [
'source' => 'EXT:test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple/Icon.svg',
'source' => 'EXT:test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple/icon.svg',
],
],
];
Expand All @@ -62,7 +62,7 @@ public static function registeredContentBlockIconsHaveCorrectConfigurationDataPr
[
'provider' => SvgIconProvider::class,
'options' => [
'source' => 'EXT:test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple2/Icon.svg',
'source' => 'EXT:test_content_blocks_c/Resources/Public/ContentBlocks/simple/simple2/icon.svg',
],
],
];
Expand All @@ -71,7 +71,7 @@ public static function registeredContentBlockIconsHaveCorrectConfigurationDataPr
[
'provider' => SvgIconProvider::class,
'options' => [
'source' => 'EXT:test_content_blocks_c/Resources/Public/ContentBlocks/simple/basics/Icon.svg',
'source' => 'EXT:test_content_blocks_c/Resources/Public/ContentBlocks/simple/basics/icon.svg',
],
],
];
Expand Down
6 changes: 3 additions & 3 deletions Tests/Functional/Generator/TcaGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function coreLabelsAreNotOverriddenIfMissingInLanguageFile(): void
public function coreLabelsAreOverriddenIfTranslationExistsInLanguageFile(): void
{
self::assertSame(
'LLL:EXT:test_content_blocks_c/ContentBlocks/ContentElements/simple2/Source/Language/Labels.xlf:header.label',
'LLL:EXT:test_content_blocks_c/ContentBlocks/ContentElements/simple2/language/labels.xlf:header.label',
$GLOBALS['TCA']['tt_content']['types']['simple_simple2']['columnsOverrides']['header']['label']
);
}
Expand Down Expand Up @@ -138,11 +138,11 @@ public function typeFieldSelectAddedForRecordType(): void
self::assertSame(
[
[
'label' => 'LLL:EXT:test_content_blocks_c/ContentBlocks/RecordTypes/record1/Source/Language/Labels.xlf:title',
'label' => 'LLL:EXT:test_content_blocks_c/ContentBlocks/RecordTypes/record1/language/labels.xlf:title',
'value' => 'record1',
'icon' => 'custom_record-record1-cc2849f',
'group' => null,
'description' => 'LLL:EXT:test_content_blocks_c/ContentBlocks/RecordTypes/record1/Source/Language/Labels.xlf:description',
'description' => 'LLL:EXT:test_content_blocks_c/ContentBlocks/RecordTypes/record1/language/labels.xlf:description',
],
[
'label' => 'content-blocks/record2',
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/ViewHelpers/LanguagePathViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public static function renderReturnsStringDataProvider(): array
return [
'name explicitly set' => [
'<cb:languagePath name="typo3tests/content-element-b" />',
'LLL:EXT:test_content_blocks_b/ContentBlocks/ContentElements/content-element-b/Source/Language/Labels.xlf',
'LLL:EXT:test_content_blocks_b/ContentBlocks/ContentElements/content-element-b/language/labels.xlf',
],
'fallback to name from context' => [
'<cb:languagePath />',
'LLL:EXT:test_content_blocks_b/ContentBlocks/ContentElements/content-element-b/Source/Language/Labels.xlf',
'LLL:EXT:test_content_blocks_b/ContentBlocks/ContentElements/content-element-b/language/labels.xlf',
],
];
}
Expand Down
Loading

0 comments on commit baafe73

Please sign in to comment.