DeletionBlockerInterface ​
- Type
- Interface
- Namespace
- craft\elements\deletionblockers
- Implemented by
- craft\elements\deletionblockers\BaseDeletionBlocker, craft\elements\deletionblockers\EntryAuthorsBlocker, craft\elements\deletionblockers\RelationDeletionBlocker
- Since
- 5.10.0
DeletionBlockerInterface defines the common interface to be implemented by element deletion blocker classes.
Public Methods ​
| Method | Description |
|---|---|
| getActions() | Returns an array of action buttons that can be taken to resolve the blocker. |
| getDetails() | Returns the blocker details HTML, to be shown when the blocker view is expanded. |
| getSummary() | Returns a text summary of the blocker. |
| isActive() | Returns whether the blocker should be shown. |
getActions() ​
Returns an array of action buttons that can be taken to resolve the blocker.
Each action button is defined by an array with the following keys:
id(optional) – The button’s IDclass(optional) – The button’s classlabel– The button’s labelicon(optional) – The button icon nameaction(optional) – The controller action that the button should trigger; if omitted, the blocker will be treated as resolved when the button is pressedparams(optional) – Additional request parameters that should be sent to the controller action (anelementIdsparam will be sent automatically)callback(optional) – JavaScript code that should be executed when the button is activateddestructive– Whether the action is destructiveconfirm(optional) – A confirmation message that should be presented to the user before triggering the actionrequireElevatedSession(optional) – Whether an elevated session is required before the action is triggeredattributes(optional) – Any HTML attributes that should be set on the<button>tag
If action is defined, the corresponding controller action can return a JSON object with the following key:
message– A message that should be shown below the blocker to indicate that it is resolved.
If callback is defined, it should be set to JavaScript code that can expect the following predefined variables:
elementType– The element type being deletedelementIds– An array of the element IDs being deletedsiteId– The site ID the elements were loaded in, if applicableownerId– The owner element ID the elements were loaded with, if applicablewithDescendants– Whether the elements are being deleted with their descendantshardDelete– Whether the elements are being hard-deletedresolve– A function that should be called once the action is resolvedreject– A function that should be called if the action is abortedblocker– TheCraft.ElementDeletionManager.Blockerinstanceaction– The current action config
A custom success message can be passed to resolve() like so:
js
resolve('This is now resolved!');getDetails() ​
Returns the blocker details HTML, to be shown when the blocker view is expanded.
getSummary() ​
Returns a text summary of the blocker.
isActive() ​
Returns whether the blocker should be shown.