You are here

protected function CopyRemoteFlow::poolsForm in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Form/CopyRemoteFlow.php \Drupal\cms_content_sync\Form\CopyRemoteFlow::poolsForm()
  2. 2.0.x src/Form/CopyRemoteFlow.php \Drupal\cms_content_sync\Form\CopyRemoteFlow::poolsForm()

Step 2: Select pools to look for existing flows for.

Parameters

bool $collapsed:

Return value

array the form

1 call to CopyRemoteFlow::poolsForm()
CopyRemoteFlow::form in src/Form/CopyRemoteFlow.php
Gets the actual form array to be built.

File

src/Form/CopyRemoteFlow.php, line 465

Class

CopyRemoteFlow
Form handler for the Pool add and edit forms.

Namespace

Drupal\cms_content_sync\Form

Code

protected function poolsForm(array $form, FormStateInterface $form_state) {
  $elements['headline'] = [
    '#markup' => '<br><br><h1>Step 2: Select pools</h1>' . '<br><br>',
  ];
  $url = $form_state
    ->getValue('url') ? $form_state
    ->getValue('url') : $_GET['url'];
  $elements['url'] = [
    '#type' => 'hidden',
    '#value' => $url,
  ];
  $options = $this
    ->getRemotePools($url);
  $create = $this
    ->getNewRemotePools($options);
  $current = \Drupal::request()
    ->getRequestUri();
  foreach ($create as $id => $name) {
    $link = Link::createFromRoute($this
      ->t('here'), 'entity.cms_content_sync_pool.add_form', [], [
      'query' => [
        'backend_url' => $url,
        'id' => $id,
        'name' => $name,
        'destination' => $current,
      ],
    ]);
    $options[$id] .= ' (' . $this
      ->t('<em>click</em> @here <em>to use in this site</em>', [
      '@here' => $link
        ->toString(),
    ]) . ')';
  }
  $elements['pools'] = [
    '#type' => 'checkboxes',
    '#options' => $options,
    '#description' => $this
      ->t("Filter by pools. This will filter the list of Flows you see next and exclude any that don't use all of the pools you selected here."),
  ];
  $elements['continue'] = [
    '#prefix' => '<br><br>',
    '#type' => 'submit',
    '#value' => $this
      ->t('Search flows'),
    '#submit' => [
      '::searchFlows',
    ],
    '#name' => 'flows',
    '#attributes' => [
      'class' => [
        'button--primary',
      ],
    ],
    '#ajax' => [
      'callback' => '::ajaxReturn',
      'wrapper' => self::CONTAINER_ID,
      'method' => 'replace',
      'effect' => 'fade',
      'progress' => [
        'type' => 'throbber',
        'message' => 'loading settings...',
      ],
    ],
  ];
  return $elements;
}