ElementActionInterface ​
- Type
- Interface
- Namespace
- craft\base
- Extends
- craft\base\ConfigurableComponentInterface
- Implemented by
- craft\base\ElementAction, craft\elements\actions\CopyReferenceTag, craft\elements\actions\CopyUrl, craft\elements\actions\DeepDuplicate, 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\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\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. |
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. |
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. |
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
(string)