Skip to content

Commit

Permalink
fix: doPublish has been deprecated in Versioned (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Jan 17, 2024
1 parent ca5c023 commit 3511161
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Extension/BaseElementExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public function onBeforeDelete()
$firstVirtual = $this->getVirtualElements()->First();
$wasPublished = false;
}

if ($firstVirtual) {
$clone = $this->owner->duplicate(false);

Expand All @@ -251,9 +252,11 @@ public function onBeforeDelete()
$clone->Sort = $firstVirtual->Sort;

$clone->write();

if ($wasPublished) {
$clone->doPublish();
$firstVirtual->doUnpublish();
$clone->publishRecursive();

$firstVirtual->doArchive();
}

// clone has a new ID, so need to repoint
Expand All @@ -262,14 +265,18 @@ public function onBeforeDelete()
if ($virtual->ID == $firstVirtual->ID) {
continue;
}

$pub = false;

if ($virtual->isPublished()) {
$pub = true;
}

$virtual->LinkedElementID = $clone->ID;
$virtual->write();

if ($pub) {
$virtual->doPublish();
$virtual->publishRecursive();
}
}

Expand Down

2 comments on commit 3511161

@lerni
Copy link
Contributor

@lerni lerni commented on 3511161 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one - just "refixed" this to discover that it's already done 🪄. This offers a hidden elemental-mover (add a virtual one and delete the original). If a release could be tagged, that would be great. Thanks!

@wilr
Copy link
Collaborator Author

@wilr wilr commented on 3511161 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.