You are here

public function ReplicateUISettingsForm::buildForm in Replicate UI 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 ConfigFormBase::buildForm

File

src/Form/ReplicateUISettingsForm.php, line 73

Class

ReplicateUISettingsForm

Namespace

Drupal\replicate_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $content_entity_types = array_filter($this->entityTypeManager
    ->getDefinitions(), function (EntityTypeInterface $entity_type) {
    return $entity_type instanceof ContentEntityTypeInterface;
  });
  $form['entity_types'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Replicate entity types'),
    '#description' => $this
      ->t('Enable replicate for the following entity types'),
    '#options' => array_map(function (EntityTypeInterface $entity_type) {
      return $entity_type
        ->getLabel();
    }, $content_entity_types),
    '#default_value' => $this
      ->config('replicate_ui.settings')
      ->get('entity_types'),
  ];
  return $form;
}