You are here

public function LockrAdminController::overview in Lockr 8.4

Same name and namespace in other branches
  1. 8.2 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()

Renders the Lockr status page.

1 string reference to 'LockrAdminController::overview'
lockr.routing.yml in ./lockr.routing.yml
lockr.routing.yml

File

src/Controller/LockrAdminController.php, line 137

Class

LockrAdminController
Controller for the Lockr admin status and configuration page.

Namespace

Drupal\lockr\Controller

Code

public function overview() {
  try {
    $info = $this->lockr
      ->getInfo();
  } catch (LockrApiException $e) {
    if ($e
      ->getCode() >= 500) {
      watchdog_exception('lockr', $e);
      $this->messenger
        ->addMessage($this
        ->t('The Lockr service has returned an error. Please try again.'), 'error');
      return [];
    }
    $info = [];
  }
  $text_config = $this->configFactory
    ->get('lockr.ui_text');
  $ra['header'] = [
    '#prefix' => '<p>',
    '#markup' => $info ? $text_config
      ->get('admin_page.header.registered') : $text_config
      ->get('admin_page.header.not_registered'),
    '#suffix' => '</p>',
  ];
  $ra['status'] = $this
    ->getStatus($info);
  $partner = $this->settingsFactory
    ->getPartner();
  if ($partner) {
    $ra['description'] = [
      '#prefix' => '<p>',
      '#markup' => $partner['description'],
      '#suffix' => '</p>',
    ];
  }
  elseif ($info && $info['env'] === 'dev') {
    $ra['migrate'] = $this->formBuilder
      ->getForm(LockrMigrateForm::class, $info);
  }

  // If register is going to attempt writing certs to the private
  // directory (when there is no partner), then only allow registration
  // if the private directory is set.
  if (!$info && ($partner || $this
    ->privateValid())) {
    $ra['register'] = $this->formBuilder
      ->getForm(LockrRegisterForm::class);
  }
  $ra['advanced'] = $this->formBuilder
    ->getForm(LockrAdvancedForm::class);
  return $ra;
}