You are here

protected function LockrAdminController::shouldRenew in Lockr 4.x

Returns how urgent renewal is.

2 calls to LockrAdminController::shouldRenew()
LockrAdminController::getStatus in src/Controller/LockrAdminController.php
Renders the Lockr status table.
LockrAdminController::overview in src/Controller/LockrAdminController.php
Renders the Lockr status page.

File

src/Controller/LockrAdminController.php, line 329

Class

LockrAdminController
Controller for the Lockr admin status and configuration page.

Namespace

Drupal\lockr\Controller

Code

protected function shouldRenew(array $auth_info) {
  switch ($auth_info['type']) {
    case 'LockrCert':
      if (is_null($auth_info['expires'])) {

        // Not sure what the default here should be.
        return REQUIREMENT_OK;
      }
      $now = new DateTimeImmutable();
      $err = new DateInterval('P1W');
      if ($now
        ->add($err) > $auth_info['expires']) {
        return REQUIREMENT_ERROR;
      }
      $warn = new DateInterval('P1M');
      if ($now
        ->add($warn) > $auth_info['expires']) {
        return REQUIREMENT_WARNING;
      }
      return REQUIREMENT_OK;
    case 'LegacyCert':

      // Legacy certs should always be renewed.
      return REQUIREMENT_ERROR;
    default:
      return REQUIREMENT_OK;
  }
}