Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Classes/ViewHelpers/Mark/ContentAreaViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

namespace TYPO3\CMS\VisualEditor\ViewHelpers\Mark;

use Exception;
use B13\Container\Tca\Registry;
use Exception;
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Page\ContentAreaClosure;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Page\PageInformation;
use TYPO3\CMS\VisualEditor\BackwardsCompatibility\ContentArea;
Expand Down Expand Up @@ -64,6 +65,11 @@ public function render(): string
$renderingContext = $this->renderingContext ?? throw new InvalidArgumentException('$this->renderingContext is not available', 1772464212);
$request = $renderingContext->getAttribute(ServerRequestInterface::class);

$renderedContentArea = $this->renderChildren();
if (!$this->editModeService->isEditMode($request)) {
return $renderedContentArea;
}

$this->editModeService->init($request);

$additionalArguments = $this->arguments;
Expand All @@ -74,7 +80,7 @@ public function render(): string

$event = $this->eventDispatcher->dispatch(
new RenderContentAreaEvent(
renderedContentArea: $this->renderChildren(),
renderedContentArea: $renderedContentArea,
contentArea: $this->getContentArea($request, $colPos, $txContainerParent),
request: $request,
),
Expand Down Expand Up @@ -109,8 +115,15 @@ private function getContentArea(ServerRequestInterface $request, int $colPos, in
/** @var PageInformation $pageInformation */
$pageInformation = $request->getAttribute('frontend.page.information');
$pageLayout = $pageInformation->getPageLayout() ?? throw new InvalidArgumentException('PageLayout is not available', 1772464283);
foreach ($pageLayout->getContentAreas() as $contentArea) {
$contentAreaCollection = $pageLayout->getContentAreas();
if ($this->typo3Version->getMajorVersion() >= 14) {
$contentAreaCollection = $contentAreaCollection->withRequest($request);
}

foreach ($contentAreaCollection as $contentArea) {
if ($this->typo3Version->getMajorVersion() >= 14) {
$contentArea = $contentArea instanceof ContentAreaClosure ? $contentArea->instantiate($request) : $contentArea;

$contentAreaColPos = $contentArea->getColPos();
$name = $contentArea->getName();
/** @var list<string> $allowed */
Expand Down
18 changes: 18 additions & 0 deletions phpstan-baseline-13.neon
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,24 @@ parameters:
count: 1
path: Classes/ViewHelpers/ImageViewHelper.php

-
message: '#^Call to method instantiate\(\) on an unknown class TYPO3\\CMS\\Core\\Page\\ContentAreaClosure\.$#'
identifier: class.notFound
count: 1
path: Classes/ViewHelpers/Mark/ContentAreaViewHelper.php

-
message: '#^Cannot call method withRequest\(\) on array\.$#'
identifier: method.nonObject
count: 1
path: Classes/ViewHelpers/Mark/ContentAreaViewHelper.php

-
message: '#^Class TYPO3\\CMS\\Core\\Page\\ContentAreaClosure not found\.$#'
identifier: class.notFound
count: 1
path: Classes/ViewHelpers/Mark/ContentAreaViewHelper.php

-
message: '#^Property TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:\$renderingContext \(TYPO3Fluid\\Fluid\\Core\\Rendering\\RenderingContextInterface\) on left side of \?\? is not nullable\.$#'
identifier: nullCoalesce.property
Expand Down
6 changes: 6 additions & 0 deletions phpstan-baseline-14.neon
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ parameters:
count: 1
path: Classes/ViewHelpers/Mark/ContentAreaViewHelper.php

-
message: '#^Instanceof between TYPO3\\CMS\\Core\\Page\\ContentArea and TYPO3\\CMS\\Core\\Page\\ContentAreaClosure will always evaluate to false\.$#'
identifier: instanceof.alwaysFalse
count: 1
path: Classes/ViewHelpers/Mark/ContentAreaViewHelper.php

-
message: '#^Property TYPO3\\CMS\\VisualEditor\\ViewHelpers\\Render\\TextViewHelper\:\:\$typo3Version on left side of \?\? is not nullable nor uninitialized\.$#'
identifier: nullCoalesce.initializedProperty
Expand Down