ElementActionInterface ​
- Type
- Interface
- Namespace
- craft\base
- Extends
- craft\base\ConfigurableComponentInterface
- Implemented by
- craft\base\ElementAction, craft\elements\actions\ChangeSortOrder, craft\elements\actions\CopyReferenceTag, craft\elements\actions\CopyUrl, craft\elements\actions\Delete, craft\elements\actions\DeleteAssets, craft\elements\actions\DeleteForSite, craft\elements\actions\DeleteUsers, craft\elements\actions\DownloadAssetFile, craft\elements\actions\Duplicate, craft\elements\actions\Edit, craft\elements\actions\EditImage, craft\elements\actions\MoveAssets, craft\elements\actions\MoveToSection, craft\elements\actions\NewChild, craft\elements\actions\NewSiblingAfter, craft\elements\actions\NewSiblingBefore, craft\elements\actions\PreviewAsset, craft\elements\actions\RenameFile, craft\elements\actions\ReplaceFile, craft\elements\actions\Restore, craft\elements\actions\SetStatus, craft\elements\actions\ShowInFolder, craft\elements\actions\SuspendUsers, craft\elements\actions\UnsuspendUsers, craft\elements\actions\View
- Since
- 3.0.0
ElementActionInterface defines the common interface to be implemented by element action classes.
Public Methods ​
Method | Description |
---|---|
displayName() | Returns the display name of this class. |
extraFields() | Returns the list of additional fields that can be returned by toArray() in addition to those listed in fields(). |
fields() | Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. |
getConfirmationMessage() | Returns a confirmation message that should be displayed before the action is performed. |
getMessage() | Returns the message that should be displayed to the user after the action is performed. |
getSettings() | Returns an array of the component’s settings. |
getSettingsHtml() | Returns the component’s settings HTML. |
getTriggerHtml() | Returns the action’s trigger HTML. |
getTriggerLabel() | Returns the action’s trigger label. |
instance() | Returns static class instance, which can be used to obtain meta information. |
isDestructive() | Returns whether this action is destructive in nature. |
isDownload() | Returns whether this is a download action. |
isSelectable() | Returns whether the component should be selectable in component Type selects. |
performAction() | Performs the action on any elements that match the given criteria. |
setElementType() | Sets the element type on the action. |
settingsAttributes() | Returns the list of settings attribute names. |
toArray() | Converts the object into an array. |
getConfirmationMessage()
​
Returns a confirmation message that should be displayed before the action is performed.
Returns ​
string, null – The confirmation message, if any.
getMessage()
​
Returns the message that should be displayed to the user after the action is performed.
Returns ​
string, null – The message that should be displayed to the user.
getTriggerHtml()
​
Returns the action’s trigger HTML.
Returns ​
string, null – The action’s trigger HTML.
getTriggerLabel()
​
Returns the action’s trigger label.
Returns ​
string – The action’s trigger label
isDestructive()
​
Returns whether this action is destructive in nature.
Returns ​
boolean – Whether this action is destructive in nature.
isDownload()
​
- Since
- 3.5.0
Returns whether this is a download action.
Download actions’ performAction() method should call one of these methods before returning true
:
- yii\web\Response::sendFile()
- yii\web\Response::sendContentAsFile()
- yii\web\Response::sendStreamAsFile()
Returns ​
boolean – Whether this is a download action
performAction()
​
Performs the action on any elements that match the given criteria.
Arguments ​
$query
(craft\elements\db\ElementQueryInterface) – The element query defining which elements the action should affect.
Returns ​
boolean – Whether the action was performed successfully.
setElementType()
​
Sets the element type on the action.
Arguments ​
$elementType
(class-string<\craft\base\ElementInterface>
)