Skip to content

Commit

Permalink
[BUGFIX] siteLanguage with fallbackType free
Browse files Browse the repository at this point in the history
Fixes: #384
Fixes: #269
  • Loading branch information
Achim Fritz committed Jun 8, 2023
1 parent 0e84d13 commit 9ed8c03
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Build/phpstan10.neon
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ parameters:
-
message: '#Call to an undefined method TYPO3\\CMS\\Frontend\\ContentObject\\RecordsContentObject::setContentObjectRenderer\(\).#'
path: %currentWorkingDirectory%/Classes/DataProcessing/ContainerProcessor.php
-
message: '#Call to protected method getTypoScriptFrontendController\(\) of class TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer.#'
path: %currentWorkingDirectory%/Classes/DataProcessing/ContainerProcessor.php
13 changes: 13 additions & 0 deletions Build/sites/main/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ languages:
fallbacks: '1'
flag: ch
languageId: '3'
- title: English-Free
enabled: true
base: /en-free/
typo3Language: default
locale: en_US.utf8
iso-639-1: en
navigationTitle: EN
hreflang: en-US
direction: ltr
fallbackType: free
fallbacks: '0'
flag: gb
languageId: '4'
rootPageId: 1
routes: { }
websiteTitle: 'Testing'
10 changes: 9 additions & 1 deletion Classes/DataProcessing/ContainerProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use B13\Container\Domain\Factory\PageView\Frontend\ContainerFactory;
use B13\Container\Domain\Model\Container;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
Expand Down Expand Up @@ -113,9 +114,16 @@ protected function processColPos(
$conf = [
'tables' => 'tt_content',
];
if ($typo3Version->getMajorVersion() < 11) {
/** @var LanguageAspect $languageAspect */
$languageAspect = $GLOBALS['TSFE']->getContext()->getAspect('language');
} else {
/** @var LanguageAspect $languageAspect */
$languageAspect = $cObj->getTypoScriptFrontendController()->getContext()->getAspect('language');
}
foreach ($children as &$child) {
if (!isset($processorConfiguration['skipRenderingChildContent']) || (int)$processorConfiguration['skipRenderingChildContent'] === 0) {
if ($child['l18n_parent'] > 0) {
if ($child['l18n_parent'] > 0 && $languageAspect->doOverlays()) {
$conf['source'] = $child['l18n_parent'];
} else {
$conf['source'] = $child['uid'];
Expand Down
10 changes: 10 additions & 0 deletions Tests/Functional/Frontend/Fixtures/SiteLanguageFree/setup.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"pages"
,"uid","pid","title","slug","sys_language_uid","l10n_parent","l10n_source"
,1,0,"page-1","/",0,0,0
,2,0,"page-1-language-4","/",4,1,1
"tt_content"
,"uid","pid","CType","header","sys_language_uid","colPos","tx_container_parent","l18n_parent","l10n_source"
,1,1,"b13-2cols-with-header-container","container-default",0,0,0,0,0
,2,1,"header","header-default",0,200,1,0,0
,3,1,"b13-2cols-with-header-container","container-translated",4,0,0,1,1
,4,1,"header","header-translated",4,200,1,2,2
42 changes: 42 additions & 0 deletions Tests/Functional/Frontend/SiteLanguageFreeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace B13\Container\Tests\Functional\Frontend;

/*
* This file is part of TYPO3 CMS-based extension "container" by b13.
*
* 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.
*/

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class SiteLanguageFreeTest extends AbstractFrontendTest
{
protected function setUp(): void
{
parent::setUp();
$this->importCSVDataSet(__DIR__ . '/Fixtures/SiteLanguageFree/setup.csv');
$this->setUpFrontendRootPage(
1,
[
'constants' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/constants.typoscript'],
'setup' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/setup.typoscript'],
]
);
}

/**
* @test
* @group frontend
*/
public function containerTranslatedInFreeModeSiteConfiguration(): void
{
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/en-free'));
$body = (string)$response->getBody();
$body = $this->prepareContent($body);
self::assertStringNotContainsString('<h2 class="">header-default</h2>', $body);
self::assertStringContainsString('<h2 class="">header-translated</h2>', $body);
}
}

0 comments on commit 9ed8c03

Please sign in to comment.