trait EntityDeleteFormTrait (View source)

Provides a trait for an entity deletion form.

This trait relies on the StringTranslationTrait and the logger method added by FormBase.

Traits

Lists affected configuration entities by a dependency removal.

Methods

t($string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

addDependencyListsToForm(array $form, string $type, array $names, ConfigManagerInterface $config_manager, EntityTypeManagerInterface $entity_type_manager)

Adds form elements to list affected configuration entities.

getEntity()

Gets the entity of this form.

LoggerInterface
logger(string $channel)

Gets the logger for a specific channel.

getQuestion()

{@inheritdoc}

getConfirmText()

{@inheritdoc}

string
getDeletionMessage()

Gets the message to display to the user after deleting the entity.

getCancelUrl()

{@inheritdoc}

Url
getRedirectUrl()

Returns the URL where the user should be redirected after deletion.

logDeletionMessage()

Logs a message about the deleted entity.

submitForm(array $form, FormStateInterface $form_state)

{@inheritdoc}

Details

abstract protected t($string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

Provided by \Drupal\Core\StringTranslation\StringTranslationTrait.

Parameters

$string
array $args
array $options

protected addDependencyListsToForm(array $form, string $type, array $names, ConfigManagerInterface $config_manager, EntityTypeManagerInterface $entity_type_manager)

Adds form elements to list affected configuration entities.

Parameters

array $form

The form array to add elements to.

string $type

The type of dependency being checked. Either 'module', 'theme', 'config' or 'content'.

array $names

The specific names to check. If $type equals 'module' or 'theme' then it should be a list of module names or theme names. In the case of 'config' or 'content' it should be a list of configuration dependency names.

ConfigManagerInterface $config_manager

The config manager.

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

See also

ConfigManagerInterface::getConfigEntitiesToChangeOnDependencyRemoval

abstract EntityInterface getEntity()

Gets the entity of this form.

Provided by \Drupal\Core\Entity\EntityForm.

Return Value

EntityInterface

The entity.

abstract protected LoggerInterface logger(string $channel)

Gets the logger for a specific channel.

Provided by \Drupal\Core\Form\FormBase.

Parameters

string $channel

The name of the channel.

Return Value

LoggerInterface

The logger for this channel.

getQuestion()

{@inheritdoc}

getConfirmText()

{@inheritdoc}

protected string getDeletionMessage()

Gets the message to display to the user after deleting the entity.

Return Value

string

The translated string of the deletion message.

getCancelUrl()

{@inheritdoc}

protected Url getRedirectUrl()

Returns the URL where the user should be redirected after deletion.

Return Value

Url

The redirect URL.

protected logDeletionMessage()

Logs a message about the deleted entity.

submitForm(array $form, FormStateInterface $form_state)

{@inheritdoc}

Parameters

array $form
FormStateInterface $form_state