Skip to content

Commit

Permalink
Ensure joining object is published on write for non-versioned owner o…
Browse files Browse the repository at this point in the history
…bjects
  • Loading branch information
michalkleiner committed Jun 18, 2021
1 parent 0f0624b commit 58abd26
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Models/DataObjectTaxonomyTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,22 @@ public function onBeforeDelete()
}
}
}


/**
* Ensure the linking object is published to Live stage after writing the owner object that doesn't have versioning.
*/
public function onAfterWrite()
{
parent::onAfterWrite();

// explicit comparison to false as using ! may not be obvious enough in this case
if ($this->OwnerObject() && $this->OwnerObject()->hasExtension(Versioned::class) === false) {
if (Versioned::get_stage() === Versioned::DRAFT) {
if ($this->canPublish()) {
$this->doPublish();
}
}
}
}
}

0 comments on commit 58abd26

Please sign in to comment.