RevisionBehavior

Type
Class
Namespace
craft\behaviors
Inherits
craft\behaviors\RevisionBehavior » yii\base\Behavior » yii\base\BaseObject
Implements
yii\base\Configurable
Since
3.2.0

RevisionBehavior is applied to element revisions.

View source

Public Properties

PropertyDescription
creatorcraft\elements\User, null
creatorIdinteger, null – The revision creator’s ID
owneryii\base\Component, null – The owner of this behavior
revisionLabelstring
revisionNotesstring, null – The revision notes
revisionNuminteger – The revision number
sourcecraft\base\ElementInterface
sourceIdinteger – The source element’s ID

creator

Type
craft\elements\User, null
Access
Read-only

View source

creatorId

Type
integer, null

The revision creator’s ID

View source

revisionLabel

Type
string
Access
Read-only

View source

revisionNotes

Type
string, null

The revision notes

View source

revisionNum

Type
integer

The revision number

View source

source

Type
craft\base\ElementInterface
Access
Read-only

View source

sourceId

Type
integer

The source element’s ID

View source

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to null.
attach()Attaches the behavior object to the component.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
detach()Detaches the behavior object from the component.
events()Declares event handlers for the owner's events.
getCreator()Returns the revision’s creator.
getRevisionLabel()Returns the revision label.
getSource()Returns the revision’s source element.
handleDelete()Deletes the row in the drafts table after the draft element is deleted.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.

events()

Declares event handlers for the owner's events.

Child classes may override this method to declare what PHP callbacks should be attached to the events of the owner component.

The callbacks will be attached to the owner's events when the behavior is attached to the owner; and they will be detached from the events when the behavior is detached from the component.

The callbacks can be any of the following:

  • method in this behavior: 'handleClick', equivalent to [$this, 'handleClick']
  • object method: [$object, 'handleClick']
  • static method: ['Page', 'handleClick']
  • anonymous function: function ($event) { ... }

The following is an example:

[
    Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate',
    Model::EVENT_AFTER_VALIDATE => 'myAfterValidate',
]

View source

Returns

array – Events (array keys) and the corresponding event handler methods (array values).

getCreator()

Returns the revision’s creator.

View source

Returns

craft\elements\User, null

getRevisionLabel()

Returns the revision label.

View source

Returns

string

getSource()

DEPRECATED

Deprecated in 3.2.9. Use craft\base\ElementInterface::getSource() instead.

Returns the revision’s source element.

View source

Returns

craft\base\ElementInterface

handleDelete()

Deletes the row in the drafts table after the draft element is deleted.

View source