You are here

private function WorkspaceConfigForm::addDefaultTargetWorkspaceSettingField in Workspace 8

1 call to WorkspaceConfigForm::addDefaultTargetWorkspaceSettingField()
WorkspaceConfigForm::buildForm in src/Form/WorkspaceConfigForm.php
Form constructor.

File

src/Form/WorkspaceConfigForm.php, line 142

Class

WorkspaceConfigForm
Class WorkspaceConfigForm.

Namespace

Drupal\workspace\Form

Code

private function addDefaultTargetWorkspaceSettingField(&$form, $config_settings) {
  $options = [];
  $workspace_pointers = WorkspacePointer::loadMultiple();
  foreach ($workspace_pointers as $workspace_pointer) {
    if ($workspace_pointer
      ->getWorkspaceAvailable() === FALSE) {
      continue;
    }

    /** @var \Drupal\multiversion\Entity\WorkspaceInterface $workspace */
    $workspace = $workspace_pointer
      ->getWorkspace();
    if ($workspace && !$workspace
      ->isPublished()) {
      continue;
    }
    $options[$workspace_pointer
      ->id()] = $workspace_pointer
      ->label();
  }
  $form['default']['upstream'] = [
    '#type' => 'select',
    '#required' => FALSE,
    '#empty_option' => $this
      ->t('- None -'),
    '#empty_value' => 0,
    '#title' => $this
      ->t('Assign default target workspace'),
    '#description' => $this
      ->t('The default workspace to push to and pull from.'),
    '#options' => $options,
    '#default_value' => $config_settings
      ->get('upstream'),
  ];
}