Skip to content

Commit

Permalink
[TASK] merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
achimfritz committed Oct 3, 2024
2 parents 43c6fba + 3916536 commit 096f47c
Show file tree
Hide file tree
Showing 66 changed files with 687 additions and 397 deletions.
6 changes: 5 additions & 1 deletion Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,11 @@ case ${TEST_SUITE} in
SUITE_EXIT_CODE=$?
;;
phpstan)
COMMAND=(php -dxdebug.mode=off .Build/bin/phpstan analyse -c Build/phpstan${TYPO3}.neon --no-progress --no-interaction --memory-limit 4G "$@")
if [ ${PHP_VERSION} == "7.4" ]; then
COMMAND=(php -dxdebug.mode=off .Build/bin/phpstan analyse -c Build/phpstan${TYPO3}-7.4.neon --no-progress --no-interaction --memory-limit 4G "$@")
else
COMMAND=(php -dxdebug.mode=off .Build/bin/phpstan analyse -c Build/phpstan${TYPO3}.neon --no-progress --no-interaction --memory-limit 4G "$@")
fi
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name phpstan-${SUFFIX} ${IMAGE_PHP} "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
Expand Down
6 changes: 6 additions & 0 deletions Build/php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

$config = \TYPO3\CodingStandards\CsFixerConfig::create();
$config->getFinder()->exclude(['var'])->in(__DIR__ . '/..');
$config->setRules([
'nullable_type_declaration' => [
'syntax' => 'question_mark',
],
'nullable_type_declaration_for_default_null_value' => true,
]);
return $config;
61 changes: 61 additions & 0 deletions Build/phpstan-baseline-11-7.4.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
parameters:
ignoreErrors:
-
message: "#^Method TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\:\\:getLanguageOverlay\\(\\) invoked with 3 parameters, 2 required\\.$#"
count: 1
path: ../Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php

-
message: "#^Constant LF not found\\.$#"
count: 4
path: ../Classes/Tca/Registry.php

-
message: "#^PHPDoc tag @return has invalid value \\(\\)\\: Unexpected token \"\\\\n \\* \", expected type at offset 679$#"
count: 1
path: ../Tests/Acceptance/Support/BackendTester.php

-
message: "#^PHPDoc tag @return has invalid value \\(\\)\\: Unexpected token \"\\\\n \\* \", expected type at offset 743$#"
count: 1
path: ../Tests/Acceptance/Support/BackendTester.php

-
message: "#^PHPDoc tag @throws with type B13\\\\Container\\\\Tests\\\\Acceptance\\\\Support\\\\_generated\\\\ConfigurationException is not subtype of Throwable$#"
count: 1
path: ../Tests/Acceptance/Support/BackendTester.php

-
message: "#^PHPDoc tag @throws with type B13\\\\Container\\\\Tests\\\\Acceptance\\\\Support\\\\_generated\\\\ModuleException is not subtype of Throwable$#"
count: 1
path: ../Tests/Acceptance/Support/BackendTester.php

-
message: "#^Call to an undefined static method TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Extension\\\\BackendEnvironment\\:\\:_initialize\\(\\)\\.$#"
count: 1
path: ../Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php

-
message: "#^Call to an undefined static method TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Extension\\\\BackendEnvironment\\:\\:bootstrapTypo3Environment\\(\\)\\.$#"
count: 1
path: ../Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php

-
message: "#^Constant ORIGINAL_ROOT not found\\.$#"
count: 1
path: ../Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php

-
message: "#^Property TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Helper\\\\AbstractPageTree\\:\\:\\$tester \\(AcceptanceTester\\) does not accept B13\\\\Container\\\\Tests\\\\Acceptance\\\\Support\\\\BackendTester\\.$#"
count: 1
path: ../Tests/Acceptance/Support/PageTree.php

-
message: "#^Constant ORIGINAL_ROOT not found\\.$#"
count: 1
path: ../Tests/Functional/Datahandler/AbstractDatahandler.php

-
message: "#^Class TYPO3\\\\CMS\\\\Backend\\\\View\\\\PageLayoutContext constructor invoked with 5 parameters, 2 required\\.$#"
count: 1
path: ../Tests/Functional/Integrity/IntegrityTest.php
11 changes: 10 additions & 1 deletion Build/phpstan-baseline-11.neon
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,13 @@ parameters:
-
message: "#^Class TYPO3\\\\CMS\\\\Backend\\\\View\\\\PageLayoutContext constructor invoked with 5 parameters, 2 required\\.$#"
count: 1
path: ../Tests/Functional/Integrity/IntegrityTest.php
path: ../Tests/Functional/Integrity/IntegrityTest.php
-
message: "#^Attribute class TYPO3\\\\CMS\\\\Install\\\\Attribute\\\\UpgradeWizard does not exist\\.$#"
count: 1
path: ../Classes/Updates/ContainerDeleteChildrenWithWrongPid.php

-
message: "#^Attribute class TYPO3\\\\CMS\\\\Install\\\\Attribute\\\\UpgradeWizard does not exist\\.$#"
count: 1
path: ../Classes/Updates/ContainerMigrateSorting.php
18 changes: 18 additions & 0 deletions Build/phpstan11-7.4.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
includes:
- phpstan-baseline-11-7.4.neon

parameters:
level: 5

paths:
- %currentWorkingDirectory%/Classes
- %currentWorkingDirectory%/Tests

excludePaths:
- %currentWorkingDirectory%/Classes/Listener/ModifyNewContentElementWizardItems.php
- %currentWorkingDirectory%/Classes/Listener/ContentUsedOnPage.php
- %currentWorkingDirectory%/Tests/Unit/Listener/ContentUsedOnPageTest.php
- %currentWorkingDirectory%/Tests/Functional/Listener/ContentUsedOnPageTest.php
- %currentWorkingDirectory%/Classes/Listener/RecordSummaryForLocalization.php
- %currentWorkingDirectory%/Classes/Listener/PageTsConfig.php

37 changes: 16 additions & 21 deletions Classes/Backend/Grid/ContainerGridColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,41 @@
*/

use B13\Container\Domain\Model\Container;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumn;
use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ContainerGridColumn extends GridColumn
{
public const CONTAINER_COL_POS_DELIMITER = '-';

protected $container;

protected $allowNewContentElements = true;

protected $newContentElementAtTopTarget;
protected ?string $newContentUrl = null;
protected bool $skipNewContentElementWizard;

public function __construct(
PageLayoutContext $context,
array $columnDefinition,
Container $container,
int $newContentElementAtTopTarget,
bool $allowNewContentElements = true
?string $newContentUrl,
bool $skipNewContentElementWizard
) {
parent::__construct($context, $columnDefinition);
$this->container = $container;
$this->allowNewContentElements = $allowNewContentElements;
$this->newContentElementAtTopTarget = $newContentElementAtTopTarget;
$this->newContentUrl = $newContentUrl;
$this->skipNewContentElementWizard = $skipNewContentElementWizard;
}

public function getContainerUid(): int
{
return $this->container->getUidOfLiveWorkspace();
}

public function getNewContentElementWizardShouldBeSkipped(): bool
{
return $this->skipNewContentElementWizard;
}

public function getTitle(): string
{
return (string)$this->getLanguageService()->sL($this->getColumnName());
Expand All @@ -56,7 +58,7 @@ public function getAllowNewContent(): bool
if ($this->container->getLanguage() > 0 && $this->container->isConnectedMode()) {
return false;
}
return $this->allowNewContentElements;
return $this->newContentUrl !== null;
}

public function isActive(): bool
Expand All @@ -67,16 +69,9 @@ public function isActive(): bool

public function getNewContentUrl(): string
{
$pageId = $this->context->getPageId();
$urlParameters = [
'id' => $pageId,
'sys_language_uid' => $this->container->getLanguage(),
'colPos' => $this->getColumnNumber(),
'tx_container_parent' => $this->container->getUidOfLiveWorkspace(),
'uid_pid' => $this->newContentElementAtTopTarget,
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('new_content_element_wizard', $urlParameters);
if ($this->newContentUrl === null) {
return '';
}
return $this->newContentUrl;
}
}
22 changes: 7 additions & 15 deletions Classes/Backend/Grid/ContainerGridColumnItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
*/

use B13\Container\Domain\Model\Container;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumn;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem;
use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ContainerGridColumnItem extends GridColumnItem
{
protected $container;
protected ?string $newContentUrl = null;

public function __construct(PageLayoutContext $context, GridColumn $column, array $record, Container $container)
public function __construct(PageLayoutContext $context, ContainerGridColumn $column, array $record, Container $container, ?string $newContentUrl)
{
parent::__construct($context, $column, $record);
$this->container = $container;
$this->newContentUrl = $newContentUrl;
}

public function getAllowNewContent(): bool
Expand All @@ -49,16 +48,9 @@ public function getWrapperClassName(): string

public function getNewContentAfterUrl(): string
{
$pageId = $this->context->getPageId();
$urlParameters = [
'id' => $pageId,
'sys_language_uid' => $this->container->getLanguage(),
'colPos' => $this->column->getColumnNumber(),
'tx_container_parent' => $this->container->getUidOfLiveWorkspace(),
'uid_pid' => -$this->record['uid'],
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('new_content_element_wizard', $urlParameters);
if ($this->newContentUrl === null) {
return '';
}
return $this->newContentUrl;
}
}
53 changes: 28 additions & 25 deletions Classes/Backend/Preview/ContainerPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@

use B13\Container\Backend\Grid\ContainerGridColumn;
use B13\Container\Backend\Grid\ContainerGridColumnItem;
use B13\Container\ContentDefender\ContainerColumnConfigurationService;
use B13\Container\Backend\Service\NewContentUrlBuilder;
use B13\Container\Domain\Factory\Exception;
use B13\Container\Domain\Factory\PageView\Backend\ContainerFactory;
use B13\Container\Domain\Service\ContainerService;
use B13\Container\Events\BeforeContainerPreviewIsRenderedEvent;
use B13\Container\Tca\Registry;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Backend\Preview\StandardContentPreviewRenderer;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\Grid;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridRow;
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;

Expand All @@ -41,33 +40,23 @@ class ContainerPreviewRenderer extends StandardContentPreviewRenderer
*/
protected $containerFactory;

/**
* @var ContainerColumnConfigurationService
*/
protected $containerColumnConfigurationService;

/**
* @var ContainerService
*/
protected $containerService;
protected NewContentUrlBuilder $newContentUrlBuilder;

/**
* @var EventDispatcher
* @var EventDispatcherInterface
*/
protected $eventDispatcher;

public function __construct(
Registry $tcaRegistry,
ContainerFactory $containerFactory,
ContainerColumnConfigurationService $containerColumnConfigurationService,
ContainerService $containerService,
EventDispatcher $eventDispatcher
NewContentUrlBuilder $newContentUrlBuilder,
EventDispatcherInterface $eventDispatcher
) {
$this->tcaRegistry = $tcaRegistry;
$this->containerFactory = $containerFactory;
$this->containerColumnConfigurationService = $containerColumnConfigurationService;
$this->containerService = $containerService;
$this->eventDispatcher = $eventDispatcher;
$this->newContentUrlBuilder = $newContentUrlBuilder;
}

public function renderPageModulePreviewContent(GridColumnItem $item): string
Expand All @@ -86,17 +75,15 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
foreach ($containerGrid as $cols) {
$rowObject = GeneralUtility::makeInstance(GridRow::class, $context);
foreach ($cols as $col) {
$newContentElementAtTopTarget = $this->containerService->getNewContentElementAtTopTargetInColumn($container, $col['colPos']);
if ($this->containerColumnConfigurationService->isMaxitemsReached($container, $col['colPos'])) {
$columnObject = GeneralUtility::makeInstance(ContainerGridColumn::class, $context, $col, $container, $newContentElementAtTopTarget, false);
} else {
$columnObject = GeneralUtility::makeInstance(ContainerGridColumn::class, $context, $col, $container, $newContentElementAtTopTarget);
}
$defVals = $this->getDefValsForContentDefenderAllowsOnlyOneSpecificContentType($record['CType'], (int)$col['colPos']);
$url = $this->newContentUrlBuilder->getNewContentUrlAtTopOfColumn($context, $container, (int)$col['colPos'], $defVals);
$columnObject = GeneralUtility::makeInstance(ContainerGridColumn::class, $context, $col, $container, $url, $defVals !== null);
$rowObject->addColumn($columnObject);
if (isset($col['colPos'])) {
$records = $container->getChildrenByColPos($col['colPos']);
foreach ($records as $contentRecord) {
$columnItem = GeneralUtility::makeInstance(ContainerGridColumnItem::class, $context, $columnObject, $contentRecord, $container);
$url = $this->newContentUrlBuilder->getNewContentUrlAfterChild($context, $container, (int)$col['colPos'], (int)$contentRecord['uid'], $defVals);
$columnItem = GeneralUtility::makeInstance(ContainerGridColumnItem::class, $context, $columnObject, $contentRecord, $container, $url);
$columnObject->addItem($columnItem);
}
}
Expand Down Expand Up @@ -126,4 +113,20 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string

return $content . $rendered;
}

protected function getDefValsForContentDefenderAllowsOnlyOneSpecificContentType(string $cType, int $colPos): ?array
{
$contentDefefenderConfiguration = $this->tcaRegistry->getContentDefenderConfiguration($cType, $colPos);
$allowedCTypes = GeneralUtility::trimExplode(',', $contentDefefenderConfiguration['allowed.']['CType'] ?? '', true);
$allowedListTypes = GeneralUtility::trimExplode(',', $contentDefefenderConfiguration['allowed.']['list_type'] ?? '', true);
if (count($allowedCTypes) === 1) {
if ($allowedCTypes[0] !== 'list') {
return ['CType' => $allowedCTypes[0]];
}
if (count($allowedListTypes) === 1) {
return ['CType' => 'list', 'list_type' => $allowedListTypes[0]];
}
}
return null;
}
}
Loading

0 comments on commit 096f47c

Please sign in to comment.