WebformOptionsDeleteForm.php in Webform 6.x
File
src/WebformOptionsDeleteForm.php
View source
<?php
namespace Drupal\webform;
use Drupal\webform\Form\WebformConfigEntityDeleteFormBase;
class WebformOptionsDeleteForm extends WebformConfigEntityDeleteFormBase {
public function getDescription() {
return [
'title' => [
'#markup' => $this
->t('This action will…'),
],
'list' => [
'#theme' => 'item_list',
'#items' => [
$this
->t('Remove configuration'),
$this
->t('Affect any elements which use these options'),
],
],
];
}
public function getDetails() {
$webform_options = $this->entity;
$webform_options_storage = $this->entityTypeManager
->getStorage('webform_options');
$t_args = [
'%label' => $this
->getEntity()
->label(),
'@entity-type' => $this
->getEntity()
->getEntityType()
->getSingularLabel(),
];
$details = [];
if ($used_by_elements = $webform_options_storage
->getUsedByCompositeElements($webform_options)) {
$details['elements'] = [
'title' => [
'#markup' => $this
->t('%label is used by the below composite element(s).', $t_args),
],
'list' => [
'#theme' => 'item_list',
'#items' => $used_by_elements,
],
];
}
if ($used_by_webforms = $webform_options_storage
->getUsedByWebforms($webform_options)) {
$details['webform'] = [
'title' => [
'#markup' => $this
->t('%label is used by the below webform(s).', $t_args),
],
'list' => [
'#theme' => 'item_list',
'#items' => $used_by_webforms,
],
];
}
if ($details) {
return [
'#type' => 'details',
'#title' => $this
->t('Webforms affected'),
] + $details;
}
else {
return [];
}
}
}