Class craft\services\EntryRevisions
- Inheritance
- craft\services\EntryRevisions » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/services/EntryRevisions.php
Entry Revisions service.
An instance of the Entry Revisions service is globally accessible in Craft via Craft::$app->entryRevisions
.
Method | Description | Defined By |
---|---|---|
__call() |
Calls the named method which is not a class method. | yii\base\BaseObject |
__clone() |
This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() |
Constructor. | yii\base\BaseObject |
__get() |
Returns the value of an object property. | yii\base\BaseObject |
__isset() |
Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() |
Sets value of an object property. | yii\base\BaseObject |
__unset() |
Sets an object property to null. | yii\base\BaseObject |
attachBehavior() |
Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() |
Attaches a list of behaviors to the component. | yii\base\Component |
behaviors() |
Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() |
Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() |
Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() |
Returns the fully qualified name of this class. | yii\base\BaseObject |
deleteDraft() |
Deletes a draft by it's model. | craft\services\EntryRevisions |
detachBehavior() |
Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() |
Detaches all behaviors from the component. | yii\base\Component |
doesEntryHaveVersions() |
Returns whether an entry has any versions stored. | craft\services\EntryRevisions |
ensureBehaviors() |
Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getBehavior() |
Returns the named behavior object. | yii\base\Component |
getBehaviors() |
Returns all behaviors attached to this component. | yii\base\Component |
getDraftById() |
Returns a draft by its ID. | craft\services\EntryRevisions |
getDraftsByEntryId() |
Returns drafts of a given entry. | craft\services\EntryRevisions |
getEditableDraftsByEntryId() |
Returns the drafts of a given entry that are editable by the current user. | craft\services\EntryRevisions |
getVersionById() |
Returns a version by its ID. | craft\services\EntryRevisions |
getVersionsByEntryId() |
Returns versions by an entry ID. | craft\services\EntryRevisions |
hasEventHandlers() |
Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() |
Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() |
Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() |
Initializes the object. | yii\base\BaseObject |
off() |
Detaches an existing event handler from this component. | yii\base\Component |
on() |
Attaches an event handler to an event. | yii\base\Component |
publishDraft() |
Publishes a draft. | craft\services\EntryRevisions |
revertEntryToVersion() |
Reverts an entry to a version. | craft\services\EntryRevisions |
saveDraft() |
Saves a draft. | craft\services\EntryRevisions |
saveVersion() |
Saves a new version. | craft\services\EntryRevisions |
trigger() |
Triggers an event. | yii\base\Component |
Method Details
deleteDraft()
public method
#
Deletes a draft by it's model.
public boolean deleteDraft ( craft\models\EntryDraft $draft )
$draft |
craft\models\EntryDraft | The draft to be deleted |
return | boolean | Whether the draft was deleted successfully |
---|
doesEntryHaveVersions()
public method
#
Returns whether an entry has any versions stored.
public boolean doesEntryHaveVersions ( \craft\services\int $entryId, \craft\services\int $siteId = null )
$entryId |
integer | The entry ID to search for |
$siteId |
integer, null | The site ID to search for |
getDraftById()
public method
#
Returns a draft by its ID.
public craft\models\EntryDraft, null getDraftById ( \craft\services\int $draftId )
$draftId |
integer |
getDraftsByEntryId()
public method
#
Returns drafts of a given entry.
public craft\models\EntryDraft[] getDraftsByEntryId ( \craft\services\int $entryId, \craft\services\int $siteId = null, \craft\services\bool $withContent = false )
$entryId |
integer | |
$siteId |
integer, null | |
$withContent |
boolean | Whether the field content should be included on the drafts |
getEditableDraftsByEntryId()
public method
#
Returns the drafts of a given entry that are editable by the current user.
public craft\models\EntryDraft[] getEditableDraftsByEntryId ( \craft\services\int $entryId, \craft\services\int $siteId = null )
$entryId |
integer | |
$siteId |
integer, null |
getVersionById()
public method
#
Returns a version by its ID.
public craft\models\EntryVersion, null getVersionById ( \craft\services\int $versionId )
$versionId |
integer |
getVersionsByEntryId()
public method
#
Returns versions by an entry ID.
public craft\models\EntryVersion[] getVersionsByEntryId ( \craft\services\int $entryId, \craft\services\int $siteId = null, \craft\services\int $limit = null, \craft\services\bool $includeCurrent = false, \craft\services\bool $withContent = false )
$entryId |
integer | The entry ID to search for. |
$siteId |
integer, null | The site ID to search for. |
$limit |
integer, null | The limit on the number of versions to retrieve. |
$includeCurrent |
boolean | Whether to include the current "top" version of the entry. |
$withContent |
boolean | Whether the field content should be included on the versions |
publishDraft()
public method
#
Publishes a draft.
public boolean publishDraft ( craft\models\EntryDraft $draft, \craft\services\bool $runValidation = true )
$draft |
craft\models\EntryDraft | The draft to be published |
$runValidation |
boolean | Whether to perform validation |
revertEntryToVersion()
public method
#
Reverts an entry to a version.
public boolean revertEntryToVersion ( craft\models\EntryVersion $version, \craft\services\bool $runValidation = true )
$version |
craft\models\EntryVersion | |
$runValidation |
boolean | Whether to perform validation |
saveDraft()
public method
#
Saves a draft.
public boolean saveDraft ( craft\models\EntryDraft $draft, \craft\services\bool $runValidation = true )
$draft |
craft\models\EntryDraft | The draft to be saved |
$runValidation |
boolean | Whether to perform validation |
saveVersion()
public method
#
Saves a new version.
public boolean saveVersion ( craft\elements\Entry $entry )
$entry |
craft\elements\Entry |
Event Details
EVENT_AFTER_DELETE_DRAFT
event of type craft\events\DraftEvent
#
The event that is triggered after a draft is deleted.
EVENT_AFTER_PUBLISH_DRAFT
event of type craft\events\DraftEvent
#
The event that is triggered after a draft is published.
EVENT_AFTER_REVERT_ENTRY_TO_VERSION
event of type craft\events\VersionEvent
#
The event that is triggered after an entry is reverted to an old version.
EVENT_AFTER_SAVE_DRAFT
event of type craft\events\DraftEvent
#
The event that is triggered after a draft is saved.
EVENT_BEFORE_DELETE_DRAFT
event of type craft\events\DraftEvent
#
The event that is triggered before a draft is deleted.
EVENT_BEFORE_PUBLISH_DRAFT
event of type craft\events\DraftEvent
#
The event that is triggered before a draft is published.
EVENT_BEFORE_REVERT_ENTRY_TO_VERSION
event of type craft\events\VersionEvent
#
The event that is triggered before an entry is reverted to an old version.
EVENT_BEFORE_SAVE_DRAFT
event of type craft\events\DraftEvent
#
The event that is triggered before a draft is saved.