You are here

public function StateTransitionConfirmForm::getDescription in State Machine 8

Returns additional text to display as a description.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup The form description.

Overrides ContentEntityConfirmFormBase::getDescription

File

src/Form/StateTransitionConfirmForm.php, line 66

Class

StateTransitionConfirmForm
Provides a confirmation form for performing an entity state transition.

Namespace

Drupal\state_machine\Form

Code

public function getDescription() {

  /** @var \Drupal\state_machine\Plugin\Field\FieldType\StateItemInterface $state_item */
  $state_item = $this->entity
    ->get($this->fieldName)
    ->first();
  $items = [
    $this
      ->t('<b>Transition</b>: @transition_label', [
      '@transition_label' => $this->transition
        ->getLabel(),
    ]),
    $this
      ->t('<b>@entity_type</b>: @entity_label', [
      '@entity_type' => $this->entity
        ->getEntityType()
        ->getLabel(),
      '@entity_label' => $this->entity
        ->label(),
    ]),
    $this
      ->t('<b>From</b>: @from_state', [
      '@from_state' => $state_item
        ->getOriginalLabel(),
    ]),
    $this
      ->t('<b>To</b>: @to_state', [
      '@to_state' => $this->transition
        ->getToState(),
    ]),
  ];
  $description = [
    'items' => [
      '#type' => 'html_tag',
      '#value' => implode('<br/>', $items),
      '#tag' => 'p',
    ],
    'warning' => [
      '#type' => 'html_tag',
      '#tag' => 'p',
      '#value' => parent::getDescription(),
    ],
  ];
  return $this->renderer
    ->renderPlain($description);
}