You are here

public function ContentExportMultiple::buildForm in Content Synchronization 8.2

Same name and namespace in other branches
  1. 3.0.x src/Form/ContentExportMultiple.php \Drupal\content_sync\Form\ContentExportMultiple::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/ContentExportMultiple.php, line 115

Class

ContentExportMultiple
Class ContentExportMultiple

Namespace

Drupal\content_sync\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $this->entityList = $this->tempStoreFactory
    ->get('content_sync_ui_multiple_confirm')
    ->get($this
    ->currentUser()
    ->id());
  if (empty($this->entityList)) {
    return new RedirectResponse($this
      ->getCancelUrl()
      ->setAbsolute()
      ->toString());
  }

  // List of items to export.
  $items = [];
  foreach ($this->entityList as $uuid => $entity_info) {
    $storage = $this->entityTypeManager
      ->getStorage($entity_info['entity_type']);
    $entity = $storage
      ->load($entity_info['entity_id']);
    if (!empty($entity)) {
      $items[$uuid] = $entity
        ->label();
    }
  }
  $form['content_list'] = [
    '#theme' => 'item_list',
    '#title' => 'Content List.',
    '#items' => $items,
  ];
  $form = parent::buildForm($form, $form_state);
  return $form;
}