function DeleteEventForm::getQuestion

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(),
    ]);
}