You are here

public function BaseTmgmtActionApproveForm::buildForm in TMGMT Extension Suite 8.3

Same name and namespace in other branches
  1. 8 src/Form/BaseTmgmtActionApproveForm.php \Drupal\tmgmt_extension_suit\Form\BaseTmgmtActionApproveForm::buildForm()
  2. 8.2 src/Form/BaseTmgmtActionApproveForm.php \Drupal\tmgmt_extension_suit\Form\BaseTmgmtActionApproveForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfirmFormBase::buildForm

File

src/Form/BaseTmgmtActionApproveForm.php, line 153

Class

BaseTmgmtActionApproveForm
Provides a confirmation form for sending multiple content entities.

Namespace

Drupal\tmgmt_extension_suit\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $temp_storage_name = $this
    ->getTempStorageName();

  // Retrieve the content to be sent from the temp store.
  $this->entityIds = $this->tempStoreFactory
    ->get($temp_storage_name)
    ->get($this
    ->currentUser()
    ->id());
  if (!$this->entityIds) {
    return new RedirectResponse($this
      ->getCancelUrl()
      ->setAbsolute()
      ->toString());
  }
  $entities = $this
    ->getEntities($this->entityIds);
  $items = [];
  foreach ($entities as $entity) {
    $items[$entity
      ->id()] = $entity
      ->label();
  }
  $form['items'] = [
    '#theme' => 'item_list',
    '#title' => $this
      ->t('Entities to process'),
    '#items' => $items,
  ];
  return ConfirmFormBase::buildForm($form, $form_state);
}