Skip to content

Commit

Permalink
Ensure joining object is deleted from draft when it's removed from live
Browse files Browse the repository at this point in the history
Applies to non-versioned owner objects.
  • Loading branch information
michalkleiner committed Jun 21, 2021
1 parent 58abd26 commit 1be37f0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Models/DataObjectTaxonomyTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,23 @@ public function onBeforeDelete()


/**
* Ensure the linking object is published to Live stage after writing the owner object that doesn't have versioning.
* Ensure the linking object is deleted from Draft when it's deleted from Live for a non-versioned owner object
*/
public function onAfterDelete()
{
if ($this->OwnerObject() && $this->OwnerObject()->hasExtension(Versioned::class) === false) {
if (Versioned::get_stage() === Versioned::LIVE) {
Versioned::withVersionedMode(function () {
Versioned::set_stage(Versioned::DRAFT);
$this->delete();
});
}
}
}


/**
* Ensure the linking object is published to Live stage after writing a non-versioned owner object
*/
public function onAfterWrite()
{
Expand Down

0 comments on commit 1be37f0

Please sign in to comment.