Documentation

DeleteContentItemsForm extends FormBase
in package

Provides a form for deleting content items.

This form enables users to delete various types of content items from the system, with a confirmation step to prevent accidental deletions. It is capable of handling HTML items, Book items, and Database items, adjusting its behavior based on the item type to ensure proper deletion of both the item and any associated links or references.

Table of Contents

Methods

access()  : AccessResult
Checks if the user can edit their own article.
buildForm()  : array<string|int, mixed>
Builds the deletion confirmation form.
getFormId()  : string
{@inheritdoc}
submitAjax()  : AjaxResponse
Handles AJAX submissions for the deletion form.
submitForm()  : void
Processes the form submission for content item deletion.
validateCheckbox()  : void
Validates the confirmation checkbox.

Methods

access()

Checks if the user can edit their own article.

public access(Request $request, AccountInterface $account) : AccessResult
Parameters
$request : Request
$account : AccountInterface
Return values
AccessResult

buildForm()

Builds the deletion confirmation form.

public buildForm(array<string|int, mixed> $form, FormStateInterface $form_state) : array<string|int, mixed>
Parameters
$form : array<string|int, mixed>

An associative array containing the initial structure of the form.

$form_state : FormStateInterface

The current state of the form.

Return values
array<string|int, mixed>

The modified form structure, including the confirmation checkbox and deletion button.

submitAjax()

Handles AJAX submissions for the deletion form.

public submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse

Provides a smoother user experience by processing form submissions via AJAX, allowing for immediate feedback without a full page reload.

Parameters
$form : array<string|int, mixed>

The form array.

$form_state : FormStateInterface

The current state of the form.

Tags
throws
EntityMalformedException
Return values
AjaxResponse

An AJAX response to update the client-side application state.

submitForm()

Processes the form submission for content item deletion.

public submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void

Executes the deletion of the specified content item, including any necessary cleanup of associated entities or references. This method ensures the item is properly removed from the system.

Parameters
$form : array<string|int, mixed>

The form array.

$form_state : FormStateInterface

The state of the form.

Tags
throws
EntityStorageException

validateCheckbox()

Validates the confirmation checkbox.

public validateCheckbox(array<string|int, mixed> &$form, FormStateInterface $form_state) : void

Ensures the user has checked the confirmation checkbox to proceed with deletion, preventing accidental deletions of content.

Parameters
$form : array<string|int, mixed>

The form array.

$form_state : FormStateInterface

The state of the form.


        
On this page

Search results