[TASK] Add possibility to purge workspaces move placeholder 68/45068/2
authorOliver Hader <oliver@typo3.org>
Mon, 30 Nov 2015 16:20:30 +0000 (17:20 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 30 Nov 2015 17:31:07 +0000 (18:31 +0100)
During resolving references in a workspace context overlays and
delete-placeholder are considered and it's possible to define
whether they are kept or substituted. This mechanism is missing
for move-placeholders as well.

Resolves: #71990
Releases: master, 6.2
Change-Id: Id0a5326c968b5ceaca2af4c092f9907a91797823
Reviewed-on: https://review.typo3.org/45068
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Classes/DataHandling/PlainDataResolver.php

index 09bef0e..801e6d5 100644 (file)
@@ -57,6 +57,11 @@ class PlainDataResolver
     protected $keepDeletePlaceholder = false;
 
     /**
+     * @var bool
+     */
+    protected $keepMovePlaceholder = true;
+
+    /**
      * @var int[]
      */
     protected $resolvedIds;
@@ -104,6 +109,16 @@ class PlainDataResolver
     }
 
     /**
+     * Sets whether move placeholders shall be kept in case they cannot be substituted.
+     *
+     * @param bool $keepMovePlaceholder
+     */
+    public function setKeepMovePlaceholder($keepMovePlaceholder)
+    {
+        $this->keepMovePlaceholder = (bool)$keepMovePlaceholder;
+    }
+
+    /**
      * @return int[]
      */
     public function get()
@@ -183,10 +198,13 @@ class PlainDataResolver
             foreach ($movePlaceholders as $movePlaceholder) {
                 $liveReferenceId = $movePlaceholder['t3ver_move_id'];
                 $movePlaceholderId = $movePlaceholder['uid'];
-                // If both, MOVE_PLACEHOLDER and MOVE_POINTER are set
-                if (isset($ids[$liveReferenceId]) && isset($ids[$movePlaceholderId])) {
+                // Substitute MOVE_PLACEHOLDER and purge live reference
+                if (isset($ids[$movePlaceholderId])) {
                     $ids[$movePlaceholderId] = $liveReferenceId;
                     unset($ids[$liveReferenceId]);
+                // Just purge live reference
+                } elseif (!$this->keepMovePlaceholder) {
+                    unset($ids[$liveReferenceId]);
                 }
             }
             $ids = $this->reindex($ids);