You are here

public function LockrAdminController::overview in Lockr 8.2

Same name and namespace in other branches
  1. 8.4 src/Controller/LockrAdminController.php \Drupal\lockr\Controller\LockrAdminController::overview()
  2. 8.3 src/Controller/LockrAdminController.php \Drupal\lockr\Controller\LockrAdminController::overview()
  3. 4.x src/Controller/LockrAdminController.php \Drupal\lockr\Controller\LockrAdminController::overview()
1 string reference to 'LockrAdminController::overview'
lockr.routing.yml in ./lockr.routing.yml
lockr.routing.yml

File

src/Controller/LockrAdminController.php, line 51

Class

LockrAdminController

Namespace

Drupal\lockr\Controller

Code

public function overview() {
  $site_client = $this->clientFactory
    ->getSiteClient();
  try {
    $status = $site_client
      ->exists();
  } catch (LockrServerException $e) {
    watchdog_exception('lockr', $e);
    drupal_set_message('The Lockr service has returned an error. Please try again.', 'error');
    return $form;
  }
  $text_config = $this->configFactory
    ->get('lockr.ui_text');
  $exists = $status['exists'];
  $ra['header'] = [
    '#prefix' => '<p>',
    '#markup' => $exists ? $text_config
      ->get('admin_page.header.registered') : $text_config
      ->get('admin_page.header.not_registered'),
    '#suffix' => '</p>',
  ];
  $ra['status'] = $this
    ->getStatus($status);
  $cert_valid = $status['cert_valid'];
  $partner = $this->partnerFactory
    ->detectPartner();
  if ($partner) {
    $ra['description'] = [
      '#prefix' => '<p>',
      '#markup' => $partner['description'],
      '#suffix' => '</p>',
    ];
  }
  elseif (!$cert_valid) {
    $ra['csr'] = $this->formBuilder
      ->getForm(LockrCSRForm::class);
  }
  elseif ($exists && $status['info']['env'] === 'dev') {
    $ra['migrate_info'] = array(
      '#prefix' => '<p>',
      '#markup' => 'Click the button below to deploy this site to production. ' . 'This should only be done in your production environment as it writes a new certificate to the file system. ',
      '#suffix' => '</p>',
    );
    $ra['migrate'] = $this->formBuilder
      ->getForm(LockrMigrateForm::class);
  }
  if (!$exists && $cert_valid) {
    $ra['register'] = $this->formBuilder
      ->getForm(LockrRegisterForm::class);
  }
  $ra['advanced'] = $this->formBuilder
    ->getForm(LockrAdvancedForm::class);
  return $ra;
}