|
14 | 14 |
|
15 | 15 | use B13\Container\Domain\Factory\ContainerFactory; |
16 | 16 | use B13\Container\Domain\Factory\Exception; |
| 17 | +use B13\Container\Domain\Service\ContainerService; |
17 | 18 | use TYPO3\CMS\Backend\Utility\BackendUtility; |
18 | 19 | use TYPO3\CMS\Core\DataHandling\DataHandler; |
19 | 20 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
@@ -50,20 +51,38 @@ protected function localizeOrCopyToLanguage(int $uid, int $language, string $com |
50 | 51 | { |
51 | 52 | try { |
52 | 53 | $container = $this->containerFactory->buildContainer($uid); |
53 | | - (GeneralUtility::makeInstance(DatahandlerProcess::class))->startContainerProcess($uid); |
| 54 | + $last = $dataHandler->copyMappingArray['tt_content'][$uid] ?? null; |
| 55 | + if ($command === 'copyToLanguage') { |
| 56 | + $containerId = $last; |
| 57 | + } else { |
| 58 | + $containerId = $uid; |
| 59 | + } |
54 | 60 | $children = $container->getChildRecords(); |
55 | | - $children = array_reverse($children); |
56 | | - $cmd = ['tt_content' => []]; |
57 | 61 | foreach ($children as $colPos => $record) { |
58 | | - $cmd['tt_content'][$record['uid']] = [$command => $language]; |
59 | | - } |
60 | | - if (count($cmd['tt_content']) > 0) { |
| 62 | + $cmd = ['tt_content' => [$record['uid'] => [$command => $language]]]; |
| 63 | + $localDataHandler = GeneralUtility::makeInstance(DataHandler::class); |
| 64 | + $localDataHandler->enableLogging = $dataHandler->enableLogging; |
| 65 | + $localDataHandler->start([], $cmd, $dataHandler->BE_USER); |
| 66 | + $localDataHandler->process_cmdmap(); |
| 67 | + $newId = $localDataHandler->copyMappingArray['tt_content'][$record['uid']] ?? null; |
| 68 | + if ($newId === null) { |
| 69 | + continue; |
| 70 | + } |
| 71 | + $cmd = ['tt_content' => [$newId=> [ |
| 72 | + 'move' => [ |
| 73 | + 'target' => -$last, |
| 74 | + 'action' => 'paste', |
| 75 | + 'update' => [ |
| 76 | + 'tx_container_parent' => $containerId, |
| 77 | + ] |
| 78 | + ] |
| 79 | + ]]]; |
61 | 80 | $localDataHandler = GeneralUtility::makeInstance(DataHandler::class); |
62 | 81 | $localDataHandler->enableLogging = $dataHandler->enableLogging; |
63 | 82 | $localDataHandler->start([], $cmd, $dataHandler->BE_USER); |
64 | 83 | $localDataHandler->process_cmdmap(); |
| 84 | + $last = $newId; |
65 | 85 | } |
66 | | - (GeneralUtility::makeInstance(DatahandlerProcess::class))->endContainerProcess($uid); |
67 | 86 | } catch (Exception $e) { |
68 | 87 | // nothing todo |
69 | 88 | } |
|
0 commit comments