Skip to content

Commit

Permalink
ENH Remove use of ChangeSets from RecursivePublishable
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Feb 12, 2025
1 parent ee61bd5 commit 6c26cdc
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/RecursivePublishable.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,21 @@ public function publishRecursive()

$owner->invokeWithExtensions('onBeforePublishRecursive', $original);

// Create a new changeset for this item and publish it
$changeset = ChangeSet::create();
$changeset->IsInferred = true;
$changeset->Name = _t(
__CLASS__ . '.INFERRED_TITLE',
"Generated by publish of '{title}' at {created}",
[
'title' => $owner->Title,
'created' => DBDatetime::now()->Nice()
]
);

$changeset->write();
$changeset->addObject($owner);

$result = $changeset->publish(true);
if (!$result) {
return $result;
// Publish this object
if ($owner->hasExtension(Versioned::class)) {
$owner->publishSingle();
}
// Recursively publish owned DataObjects
foreach ($owner->findOwned(true) as $obj) {
if ($obj->hasExtension(Versioned::class)) {
$obj->publishSingle();
}
}

$owner->invokeWithExtensions('onAfterPublishRecursive', $original);

return $result;
// return $result;
return true;
});
}

Expand Down

0 comments on commit 6c26cdc

Please sign in to comment.