function DeleteEventForm::getQuestion

Returns the question to ask the user.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup The form question. The page title will be set to this value.

Overrides ConfirmFormInterface::getQuestion

File

src/Form/DeleteEventForm.php, line 107

Class

DeleteEventForm
Removes an event from a rule.

Namespace

Drupal\rules\Form

Code

public function getQuestion() {
  // Do not allow to delete an event if there's only one.
  if (count($this->reactionRule
    ->getEvents()) === 1) {
    throw new AccessDeniedHttpException('An event cannot be deleted if the reaction rule has only one.');
  }
  // Check of the event requested to be deleted, exists.
  if (!$this->reactionRule
    ->hasEvent($this->id)) {
    throw new NotFoundHttpException();
  }
  $event_definition = $this->eventManager
    ->getDefinition($this->id);
  return $this->t('Are you sure you want to delete the event %title from %rule?', [
    '%title' => $event_definition['label'],
    '%rule' => $this->rulesUiHandler
      ->getComponentLabel(),
  ]);
}