Skip to content

Commit

Permalink
Finished campaign revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Mar 14, 2022
1 parent 604ae4a commit db15fa3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/elements/CampaignElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\elements\actions\Edit;
use craft\elements\actions\Restore;
use craft\elements\actions\View as ViewAction;
use craft\elements\Entry;
use craft\elements\User;
use craft\helpers\Cp;
use craft\helpers\Html;
Expand Down Expand Up @@ -817,6 +818,36 @@ public function afterSave(bool $isNew): void
parent::afterSave($isNew);
}

/**
* @inheritdoc
*/
public function afterPropagate(bool $isNew): void
{
parent::afterPropagate($isNew);

// Save a new revision?
if ($this->_shouldSaveRevision()) {
Craft::$app->getRevisions()->createRevision($this, $this->revisionCreatorId, $this->revisionNotes);
}
}

/**
* Returns whether the entry should be saving revisions on save.
*
* @see Entry::_shouldSaveRevision()
* @return bool
*/
private function _shouldSaveRevision(): bool
{
return (
$this->id &&
!$this->propagating &&
!$this->resaving &&
!$this->getIsDraft() &&
!$this->getIsRevision()
);
}

/**
* Returns the campaign's body
*/
Expand Down

0 comments on commit db15fa3

Please sign in to comment.