You are here

protected function CopyRemoteFlow::syncCoreForm 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::syncCoreForm()
  2. 2.0.x src/Form/CopyRemoteFlow.php \Drupal\cms_content_sync\Form\CopyRemoteFlow::syncCoreForm()

Step 1: Select Sync Core or enter new Sync Core URL.

Parameters

bool $collapsed:

Return value

array the form

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

File

src/Form/CopyRemoteFlow.php, line 416

Class

CopyRemoteFlow
Form handler for the Pool add and edit forms.

Namespace

Drupal\cms_content_sync\Form

Code

protected function syncCoreForm(array $form, FormStateInterface $form_state) {
  $elements['headline'] = [
    '#markup' => '<br><br><h1>Step 1: Pick Sync Core</h1>' . '<br><br>',
  ];
  $pools = Pool::getAll();
  $urls = [];
  foreach ($pools as $existing_pool) {
    $url = $existing_pool
      ->getSyncCoreUrl();
    $urls[$url] = Helper::obfuscateCredentials($url);
  }
  if (count($urls)) {
    foreach ($urls as $url => $name) {
      $elements['headline']['#markup'] .= '<a href="?url=' . urlencode($url) . '">' . $name . '</a><br>';
    }
    $elements['headline']['#markup'] .= '<br><br><h2>-OR-</h2><br><br>';
  }
  $elements['url'] = [
    '#type' => 'url',
    '#default_value' => isset($_GET['url']) ? $_GET['url'] : null,
    '#title' => $this
      ->t('Enter Sync Core URL'),
    '#description' => $this->syncCoreError ? $this->syncCoreError
      ->getMessage() : '',
  ];
  $elements['continue'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Connect'),
    '#name' => 'connect',
    '#attributes' => [
      'class' => [
        'button--primary',
      ],
    ],
  ];
  return $elements;
}