-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] !!! sorting of content elements
behaviour of sorting is changed in two ways: * element at first position in container column * old: pid was used as target (leeds to broken sorting) * new: use -uid of container element for first column * new: use -uid of previous column child (if exists), (else -uid of container) * element after a container * old: -uid of container is used (leeds to broken sorting) * new: -uid of last child in containers last column is used we shift a migration command to fix broken sorting: dry-run: container:sorting run: container:sorting 0 must be called multiple for nested containers Fixes: #149
- Loading branch information
Achim Fritz
committed
May 20, 2022
1 parent
625ad7c
commit a1cc4de
Showing
47 changed files
with
1,473 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace B13\Container\Command; | ||
|
||
/* | ||
* 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 B13\Container\Integrity\Sorting; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use TYPO3\CMS\Core\Core\Bootstrap; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class SortingCommand extends Command | ||
{ | ||
|
||
/** | ||
* @var Sorting | ||
*/ | ||
protected $sorting; | ||
|
||
protected function configure() | ||
{ | ||
$this->addArgument('dryrun', InputArgument::OPTIONAL, 'do not execute queries', true); | ||
} | ||
|
||
public function __construct(string $name = null, Sorting $sorting = null) | ||
{ | ||
parent::__construct($name); | ||
$this->sorting = $sorting ?? GeneralUtility::makeInstance(Sorting::class); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
*/ | ||
public function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$dryrun = (bool)$input->getArgument('dryrun'); | ||
Bootstrap::initializeBackendAuthentication(); | ||
Bootstrap::initializeLanguageObject(); | ||
$errors = $this->sorting->run($dryrun); | ||
foreach ($errors as $error) { | ||
$output->writeln($error); | ||
} | ||
if (empty($errors)) { | ||
$output->writeln('migration finished'); | ||
} | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace B13\Container\Domain\Service; | ||
|
||
/* | ||
* 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 B13\Container\Domain\Factory\ContainerFactory; | ||
use B13\Container\Domain\Model\Container; | ||
use B13\Container\Tca\Registry; | ||
use TYPO3\CMS\Core\SingletonInterface; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class ContainerService implements SingletonInterface | ||
{ | ||
/** | ||
* @var Registry | ||
*/ | ||
protected $tcaRegistry; | ||
|
||
/** | ||
* @var ContainerFactory | ||
*/ | ||
protected $containerFactory; | ||
|
||
public function __construct(Registry $tcaRegistry = null, ContainerFactory $containerFactory = null) | ||
{ | ||
$this->tcaRegistry = $tcaRegistry ?? GeneralUtility::makeInstance(Registry::class); | ||
$this->containerFactory = $containerFactory ?? GeneralUtility::makeInstance(ContainerFactory::class); | ||
} | ||
|
||
public function getNewContentElementAtTopTargetInColumn(Container $container, int $targetColPos): int | ||
{ | ||
$target = -$container->getUid(); | ||
$previousRecord = null; | ||
$allColumns = $this->tcaRegistry->getAllAvailableColumnsColPos($container->getCType()); | ||
foreach ($allColumns as $colPos) { | ||
if ($colPos === $targetColPos && $previousRecord !== null) { | ||
$target = -$previousRecord['uid']; | ||
} | ||
$children = $container->getChildrenByColPos($colPos); | ||
if (!empty($children)) { | ||
$last = array_pop($children); | ||
$previousRecord = $last; | ||
} | ||
} | ||
return $target; | ||
} | ||
|
||
public function getAfterContainerElementTarget(Container $container): int | ||
{ | ||
$target = -$container->getUid(); | ||
$containerRecord = $container->getContainerRecord(); | ||
$childRecords = $container->getChildRecords(); | ||
if (empty($childRecords)) { | ||
return $target; | ||
} | ||
$lastChild = array_pop($childRecords); | ||
if (!$this->tcaRegistry->isContainerElement($lastChild['CType'])) { | ||
return -$lastChild['uid']; | ||
} | ||
$container = $this->containerFactory->buildContainer($lastChild['uid']); | ||
return $this->getAfterContainerElementTarget($container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This line seems to be the cause for #500