You are here

public function LockrAdminController::getStatus in Lockr 8.4

Same name and namespace in other branches
  1. 8.2 src/Controller/LockrAdminController.php \Drupal\lockr\Controller\LockrAdminController::getStatus()
  2. 8.3 src/Controller/LockrAdminController.php \Drupal\lockr\Controller\LockrAdminController::getStatus()
  3. 4.x src/Controller/LockrAdminController.php \Drupal\lockr\Controller\LockrAdminController::getStatus()

Renders the Lockr status table.

1 call to LockrAdminController::getStatus()
LockrAdminController::overview in src/Controller/LockrAdminController.php
Renders the Lockr status page.

File

src/Controller/LockrAdminController.php, line 189

Class

LockrAdminController
Controller for the Lockr admin status and configuration page.

Namespace

Drupal\lockr\Controller

Code

public function getStatus(array $info) {
  require_once "{$this->drupalRoot}/core/includes/install.inc";
  $text_config = $this->configFactory
    ->get('lockr.ui_text');
  $reqs = [];
  if ($info) {
    $reqs[] = [
      'title' => $this
        ->t('Certificate Valid'),
      'value' => $this
        ->t('Yes'),
      'description' => $text_config
        ->get('admin_page.status.registered'),
      'severity' => REQUIREMENT_OK,
    ];
    $reqs[] = [
      'title' => $this
        ->t('Environment'),
      'value' => ucfirst($info['env']),
      'severity' => REQUIREMENT_INFO,
    ];
  }
  else {
    $private_valid = $this
      ->privateValid();
    $reqs[] = [
      'title' => $this
        ->t('Private Directory'),
      'value' => $private_valid ? $this->fileSystem
        ->realpath('private://') : $this
        ->t('Unknown'),
      'description' => $private_valid ? $text_config
        ->get('admin_page.status.path.exists') : $text_config
        ->get('admin_page.status.path.invalid'),
      'severity' => $private_valid ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    ];
    $reqs[] = [
      'title' => $this
        ->t('Certificate Valid'),
      'value' => $this
        ->t('No'),
      'description' => $text_config
        ->get('admin_page.status.not_registered'),
    ];
  }
  if ($info) {
    $reqs[] = [
      'title' => $this
        ->t('Connected KeyRing'),
      'value' => $this
        ->t('Yes'),
      'description' => $this
        ->t("You are currently connected to the @label KeyRing.", [
        '@label' => $info['keyring']['label'],
      ]),
      'severity' => REQUIREMENT_OK,
    ];
    $has_cc = $info['keyring']['hasCreditCard'];
    if (isset($info['keyring']['trialEnd'])) {
      $trial_end = \DateTime::createFromFormat(\DateTime::RFC3339, $info['keyring']['trialEnd']);
      if ($trial_end > new \DateTime()) {
        $reqs[] = [
          'title' => $this
            ->t('Trial Expiration Date'),
          'value' => $trial_end
            ->format('M jS, Y'),
          'severity' => REQUIREMENT_INFO,
        ];
      }
      elseif (!$has_cc) {
        $reqs[] = [
          'title' => $this
            ->t('Trial Expiration Date'),
          'value' => $trial_end
            ->format('M jS, Y'),
          'severity' => REQUIREMENT_ERROR,
        ];
      }
    }
    $reqs[] = [
      'title' => $this
        ->t('Credit Card on File'),
      'value' => $has_cc ? 'Yes' : 'No',
      'description' => $has_cc ? $text_config
        ->get('admin_page.status.cc.has') : $text_config
        ->get('admin_page.status.cc.missing.required'),
      'severity' => $has_cc ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    ];
  }
  lockr_preprocess_status_report($reqs);
  return [
    '#theme' => 'status_report',
    '#requirements' => $reqs,
  ];
}