@@ -27,9 +27,12 @@ class CommandMapPostProcessingHook
2727 */
2828 protected $ containerFactory ;
2929
30- public function __construct (ContainerFactory $ containerFactory )
30+ protected ContainerService $ containerService ;
31+
32+ public function __construct (ContainerFactory $ containerFactory , ContainerService $ containerService )
3133 {
3234 $ this ->containerFactory = $ containerFactory ;
35+ $ this ->containerService = $ containerService ;
3336 }
3437
3538 public function processCmdmap_postProcess (string $ command , string $ table , $ id , $ value , DataHandler $ dataHandler , $ pasteUpdate , $ pasteDatamap ): void
@@ -54,6 +57,19 @@ protected function localizeOrCopyToLanguage(int $uid, int $language, string $com
5457 $ last = $ dataHandler ->copyMappingArray ['tt_content ' ][$ uid ] ?? null ;
5558 if ($ command === 'copyToLanguage ' ) {
5659 $ containerId = $ last ;
60+ $ pos = $ this ->containerService ->getAfterContainerElementTarget ($ container );
61+ // move next record after last child
62+ $ cmd = ['tt_content ' => [$ last => [
63+ 'move ' => [
64+ 'target ' => $ pos ,
65+ 'action ' => 'paste ' ,
66+ 'update ' => [],
67+ ]
68+ ]]];
69+ $ localDataHandler = GeneralUtility::makeInstance (DataHandler::class);
70+ $ localDataHandler ->enableLogging = $ dataHandler ->enableLogging ;
71+ $ localDataHandler ->start ([], $ cmd , $ dataHandler ->BE_USER );
72+ $ localDataHandler ->process_cmdmap ();
5773 } else {
5874 $ containerId = $ container ->getUid ();
5975 }
@@ -132,6 +148,18 @@ protected function copyOrMoveChildren(int $origUid, int $newId, int $containerId
132148 $ localDataHandler ->enableLogging = $ dataHandler ->enableLogging ;
133149 $ localDataHandler ->start ([], $ cmd , $ dataHandler ->BE_USER );
134150 $ localDataHandler ->process_cmdmap ();
151+ if (!isset ($ origCmdMap ['tt_content ' ][$ origUid ][$ command ]['update ' ]['sys_language_uid ' ])) {
152+ continue ;
153+ }
154+ if ($ origCmdMap ['tt_content ' ][$ origUid ][$ command ]['update ' ]['sys_language_uid ' ] === $ record ['sys_language_uid ' ]) {
155+ continue ;
156+ }
157+ $ target = -$ record ['uid ' ];
158+ // copy case
159+ $ newId = $ localDataHandler ->copyMappingArray ['tt_content ' ][$ record ['uid ' ]] ?? null ;
160+ if ($ newId !== null ) {
161+ $ target = -$ newId ;
162+ }
135163 }
136164 (GeneralUtility::makeInstance (DatahandlerProcess::class))->endContainerProcess ($ origUid );
137165 } catch (Exception $ e ) {
0 commit comments