You are here

public function LaunchImportForm::buildForm in Content Synchronizer 8.2

Same name and namespace in other branches
  1. 8 src/Form/LaunchImportForm.php \Drupal\content_synchronizer\Form\LaunchImportForm::buildForm()
  2. 3.x src/Form/LaunchImportForm.php \Drupal\content_synchronizer\Form\LaunchImportForm::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 FormInterface::buildForm

File

src/Form/LaunchImportForm.php, line 43

Class

LaunchImportForm
Launch Import Form.

Namespace

Drupal\content_synchronizer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\content_synchronizer\Entity\ImportEntity $import */
  $this->import = $form_state
    ->getBuildInfo()['import'];
  if ($this->import
    ->getProcessingStatus() === ImportEntity::STATUS_NOT_STARTED) {

    // Settings.
    $form['settings'] = [
      '#type' => 'fieldset',
      '#title' => t('Settings'),
    ];
    $form['settings']['creationType'] = [
      '#type' => 'radios',
      '#title' => t(static::CREATION_ACTION_LABEL),
      '#options' => static::getCreateOptions(),
      '#default_value' => ImportProcessor::PUBLICATION_PUBLISH,
    ];
    $form['settings']['updateType'] = [
      '#type' => 'radios',
      '#title' => t(static::UPDATE_ACTION_LABEL),
      '#options' => static::getUpdateOptions(),
      '#default_value' => ImportProcessor::UPDATE_IF_RECENT,
    ];
  }

  // Entity list.
  $this
    ->initRootEntitiesList($form);
  if ($this->import
    ->getProcessingStatus() === ImportEntity::STATUS_NOT_STARTED) {
    $form['launch'] = [
      '#type' => 'submit',
      '#value' => t('Import selected entities'),
      '#button_type' => 'primary',
    ];
  }
  return $form;
}