public function LockrAdminController::getStatus in Lockr 4.x
Same name and namespace in other branches
- 8.4 src/Controller/LockrAdminController.php \Drupal\lockr\Controller\LockrAdminController::getStatus()
- 8.2 src/Controller/LockrAdminController.php \Drupal\lockr\Controller\LockrAdminController::getStatus()
- 8.3 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 203
Class
- LockrAdminController
- Controller for the Lockr admin status and configuration page.
Namespace
Drupal\lockr\ControllerCode
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 = $this->streamWrapperManager
->getViaScheme('private');
$value = $this
->t('Unknown');
if ($private) {
$realpath = $private
->realpath();
if ($realpath) {
$value = $realpath;
}
}
$reqs[] = [
'title' => $this
->t('Private Directory'),
'value' => $realpath,
'description' => $private ? $text_config
->get('admin_page.status.path.exists') : $text_config
->get('admin_page.status.path.invalid'),
'severity' => $private ? 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,
];
$auth_info = $this
->extractExpires($info);
$sev = $this
->shouldRenew($auth_info);
if ($sev !== REQUIREMENT_OK) {
$reqs[] = [
'title' => $this
->t('Certificate Expiration'),
'value' => $auth_info['expires']
->format('M jS, Y'),
'description' => $this
->t('Your certificate is close to expiration.'),
'severity' => $sev,
];
}
}
lockr_preprocess_status_report($reqs);
return [
'#type' => 'status_report',
'#requirements' => $reqs,
];
}