You are here

public function ContentHubImportQueueForm::buildForm in Acquia Content Hub 8.2

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

modules/acquia_contenthub_subscriber/src/Form/ContentHubImportQueueForm.php, line 77

Class

ContentHubImportQueueForm
The form for content hub import queues.

Namespace

Drupal\acquia_contenthub_subscriber\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['description'] = [
    '#markup' => $this
      ->t('Instruct the content hub module to manage content syndication with a queue.'),
  ];
  $form['run_import_queue'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Run the import queue'),
    '#description' => '<strong>For development & testing use only!</strong><br /> Running the import queue from the UI can cause php timeouts for large datasets.
                         A cronjob to run the queue should be used instead.',
    '#open' => TRUE,
  ];
  $form['run_import_queue']['actions'] = [
    '#type' => 'actions',
  ];
  $queue_count = $this->contentHubImportQueue
    ->getQueueCount();
  $form['run_import_queue']['queue_list'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('Number of items in the import queue'),
    '#description' => $this
      ->t('%num @items', [
      '%num' => $queue_count,
      '@items' => $queue_count == 1 ? 'item' : 'items',
    ]),
  ];
  $form['run_import_queue']['actions']['run'] = [
    '#type' => 'submit',
    '#name' => 'run_import_queue',
    '#value' => $this
      ->t('Run import queue'),
    '#op' => 'run',
  ];
  $title = $this
    ->t('Queue from filters');
  $form['queue_from_filters'] = [
    '#type' => 'details',
    '#title' => $title,
    '#description' => 'Queue entities for import based on your custom filters',
    '#open' => TRUE,
  ];
  $form['queue_from_filters']['actions'] = [
    '#type' => 'actions',
  ];
  $form['queue_from_filters']['actions']['import'] = [
    '#type' => 'submit',
    '#name' => 'queue_from_filters',
    '#value' => $title,
  ];
  return $form;
}