You are here

public function DeleteUpdateForm::getQuestion in Scheduled Publish 8.3

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/DeleteUpdateForm.php, line 43
Contains \Drupal\scheduled_publish\Form\DeleteUpdateForm.

Class

DeleteUpdateForm

Namespace

Drupal\scheduled_publish\Form

Code

public function getQuestion() {
  $states = $this->entity
    ->get($this->field)
    ->getValue();
  $prev_state = $states[$this->field_delta - 1] ?? FALSE;
  if ($prev_state) {
    $orig_status = $this->entity->moderation_state->value;
    $this->entity->moderation_state->value = $prev_state['moderation_state'];
  }
  $m_options = $this
    ->getModerationOptions($this->entity);
  if ($prev_state) {
    $this->entity->moderation_state->value = $orig_status;
  }
  $state_display = $states[$this->field_delta]['moderation_state'];
  if (isset($m_options[$states[$this->field_delta]['moderation_state']])) {
    $state_display = $m_options[$states[$this->field_delta]['moderation_state']];
    $state_display .= ' (';
    $state_display .= $states[$this->field_delta]['moderation_state'];
    $state_display .= ')';
  }
  $entity_info = $this->entity
    ->label() . ' (' . $this->entity
    ->id() . ')';
  $date = new DrupalDateTime($states[$this->field_delta]['value'], date_default_timezone_get());
  $date_display = $date
    ->format('d.m.Y - H:i');
  return $this
    ->t('Are you sure you want to delete "@state on @date" status update for the "@node" node?', [
    '@node' => $entity_info,
    '@state' => $state_display,
    '@date' => $date_display,
  ]);
}