You are here

public function WebformOptionsDeleteForm::getDetails in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformOptionsDeleteForm.php \Drupal\webform\WebformOptionsDeleteForm::getDetails()

Returns details to display.

Return value

array A renderable array containing details.

Overrides WebformConfigEntityDeleteFormBase::getDetails

File

src/WebformOptionsDeleteForm.php, line 33

Class

WebformOptionsDeleteForm
Provides a delete webform options form.

Namespace

Drupal\webform

Code

public function getDetails() {

  /** @var \Drupal\webform\WebformOptionsInterface $webform_options */
  $webform_options = $this->entity;

  /** @var \Drupal\webform\WebformOptionsStorageInterface $webform_options_storage */
  $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 [];
  }
}