You are here

public function BulkNodeExport::buildForm in Node export 8

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 FormInterface::buildForm

File

src/Form/BulkNodeExport.php, line 100

Class

BulkNodeExport
Provides a Node Export form.

Namespace

Drupal\node_Export\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $this
    ->messenger()
    ->addWarning($this
    ->t('This module is experiemental. PLEASE do not use on production databases without prior testing and a complete database dump.'));
  $this->userInput['entities'] = $this->tempStoreFactory
    ->get('node_export_ids')
    ->get($this->currentUser
    ->id());
  $json = NodeExport::export(array_keys($this->userInput['entities']), 'json', FALSE);
  $form['export_code'] = [
    '#type' => 'textarea',
    '#value' => $json,
    '#title' => $this
      ->t('Node Export Code is :'),
    '#rows' => '15',
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Download'),
  ];
  return $form;
}