Skip to content

Commit

Permalink
[BUGFIX] Get translated version of content record before rendering in FE
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Aug 5, 2023
1 parent 9fc8102 commit fc5464f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
16 changes: 14 additions & 2 deletions Classes/Controller/AbstractFluxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use FluidTYPO3\Flux\Provider\Interfaces\DataStructureProviderInterface;
use FluidTYPO3\Flux\Provider\Interfaces\FluidProviderInterface;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use FluidTYPO3\Flux\Utility\ExtensionNamingUtility;
use FluidTYPO3\Flux\Utility\RecursiveArrayUtility;
use FluidTYPO3\Flux\ViewHelpers\FormViewHelper;
Expand Down Expand Up @@ -56,16 +57,19 @@ abstract class AbstractFluxController extends ActionController
protected RenderingContextBuilder $renderingContextBuilder;
protected RequestBuilder $requestBuilder;
protected FluxService $configurationService;
protected WorkspacesAwareRecordService $recordService;
protected ?ControllerProviderInterface $provider = null;

public function __construct(
FluxService $fluxService,
RenderingContextBuilder $renderingContextBuilder,
RequestBuilder $requestBuilder
RequestBuilder $requestBuilder,
WorkspacesAwareRecordService $recordService
) {
$this->configurationService = $fluxService;
$this->renderingContextBuilder = $renderingContextBuilder;
$this->requestBuilder = $requestBuilder;
$this->recordService = $recordService;

/** @var Arguments $arguments */
$arguments = GeneralUtility::makeInstance(Arguments::class);
Expand Down Expand Up @@ -537,7 +541,15 @@ public function getRecord(): array
1666538343
);
}
return $contentObject->data;
$record = $contentObject->data;
if ($record['_LOCALIZED_UID'] ?? false) {
$record = $this->recordService->getSingle(
(string) $this->getFluxTableName(),
'*',
$record['_LOCALIZED_UID']
) ?? $record;
}
return $record;
}

protected function getServerRequest(): ServerRequestInterface
Expand Down
4 changes: 3 additions & 1 deletion Tests/Fixtures/Classes/DummyPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use FluidTYPO3\Flux\Provider\Interfaces\ControllerProviderInterface;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Service\PageService;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use PHPUnit\Framework\MockObject\Generator;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;

Expand All @@ -26,7 +27,8 @@ public function __construct()
$fluxService = $this->createMock(FluxService::class);
$renderingContextBuilder = $this->createMock(RenderingContextBuilder::class);
$requestBuilder = $this->createMock(RequestBuilder::class);
parent::__construct($fluxService, $renderingContextBuilder, $requestBuilder);
$recordService = $this->createMock(WorkspacesAwareRecordService::class);
parent::__construct($fluxService, $renderingContextBuilder, $requestBuilder, $recordService);
}

public function setView(ViewInterface $view): void
Expand Down
2 changes: 2 additions & 0 deletions Tests/Unit/Controller/AbstractFluxControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use FluidTYPO3\Flux\Provider\Provider;
use FluidTYPO3\Flux\Provider\ProviderInterface;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use FluidTYPO3\Flux\Tests\Fixtures\Data\Records;
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -91,6 +92,7 @@ protected function getConstructorArguments(): array
$this->fluxService,
$this->renderingContextBuilder,
$this->requestBuilder,
$this->getMockBuilder(WorkspacesAwareRecordService::class)->disableOriginalConstructor()->getMock(),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use FluidTYPO3\Flux\Provider\ProviderInterface;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use FluidTYPO3\Flux\Tests\Fixtures\Classes\DummyPageController;
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use FluidTYPO3\Flux\Utility\ExtensionConfigurationUtility;
Expand Down Expand Up @@ -84,7 +85,8 @@ protected function getControllerConstructorArguments(): array
return [
$this->fluxService,
$this->renderingContextBuilder,
$this->requestBuilder
$this->requestBuilder,
$this->getMockBuilder(WorkspacesAwareRecordService::class)->disableOriginalConstructor()->getMock(),
];
}

Expand Down

0 comments on commit fc5464f

Please sign in to comment.