You are here

public function SendContextActionApproveForm::buildForm in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8 src/Form/SendContextActionApproveForm.php \Drupal\tmgmt_smartling\Form\SendContextActionApproveForm::buildForm()
  2. 8.2 src/Form/SendContextActionApproveForm.php \Drupal\tmgmt_smartling\Form\SendContextActionApproveForm::buildForm()
  3. 8.3 src/Form/SendContextActionApproveForm.php \Drupal\tmgmt_smartling\Form\SendContextActionApproveForm::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/SendContextActionApproveForm.php, line 188

Class

SendContextActionApproveForm
Provides a confirmation form for sending multiple content entities.

Namespace

Drupal\tmgmt_smartling\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());
  }
  $items = [];
  $entities = $this
    ->getEntities($this->entityIds);
  foreach ($entities as $entity) {
    $items[$entity
      ->id()] = $entity
      ->label();
  }
  $form['items'] = [
    '#theme' => 'item_list',
    '#title' => $this
      ->t('Entities to contextualize'),
    '#items' => $items,
  ];
  return ConfirmFormBase::buildForm($form, $form_state);
}