Documentation

DeletePageForm extends FormBase
in package

Form handler for deleting a single page or an entire guide.

Presents a confirmation form to the user for deleting a selected page from a guide or the guide itself, including the option to delete all subpages and associated content. It dynamically adjusts the confirmation message based on whether a guide or a single page is being deleted.

Table of Contents

Methods

access()  : AccessResult
Checks if the user can edit their own article.
buildForm()  : array<string|int, mixed>
Constructs the delete page form.
getFormId()  : string
{@inheritdoc}
PageSelectedCallBack()  : array<string|int, mixed>
AJAX callback for dynamically updating the form based on page selection.
submitAjax()  : AjaxResponse
Submits the form using AJAX, providing immediate user feedback.
submitForm()  : void
Processes the deletion of the selected page or guide upon form submission.

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()

Constructs the delete page 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 structure of the form.

$form_state : FormStateInterface

The current state of the form.

Return values
array<string|int, mixed>

The form structure.

getFormId()

{@inheritdoc}

public getFormId() : string
Return values
string

PageSelectedCallBack()

AJAX callback for dynamically updating the form based on page selection.

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

Updates the form's confirmation message and visibility of certain form elements based on the selected page. Adjusts the message for guide deletion or single page deletion and handles the presence of subpages.

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

The form array.

$form_state : FormStateInterface

The current state of the form.

Return values
array<string|int, mixed>

The updated portion of the form.

submitAjax()

Submits the form using AJAX, providing immediate user feedback.

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

Handles the AJAX form submission, allowing for a smoother user experience by providing feedback directly in the modal dialog without requiring a page refresh. It constructs an appropriate success message based on the content type that was deleted.

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

The form array.

$form_state : FormStateInterface

The state of the form.

Tags
throws
EntityMalformedException
Return values
AjaxResponse

The AJAX response for the form submission.

submitForm()

Processes the deletion of the selected page or guide upon form submission.

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

Executes the deletion logic for the selected content, removing it from the system. It handles the deletion of a single page, all its subpages, and associated content if specified, or an entire guide and its structure.

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

The form array.

$form_state : FormStateInterface

The state of the form.


        
On this page

Search results