public static function LPStatus::getCertificateExpirationMessage in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Entity/LPStatus.php \Drupal\opigno_learning_path\Entity\LPStatus::getCertificateExpirationMessage()
Returns training certificate expiration message.
Parameters
int $gid: Group ID.
int $uid: User ID.
string $type: Message text type 'valid'|'expired'|null.
Return value
string Training certificate expiration message.
1 call to LPStatus::getCertificateExpirationMessage()
- opigno_learning_path_tokens in ./opigno_learning_path.tokens.inc 
- Implements hook_tokens().
File
- src/Entity/ LPStatus.php, line 534 
Class
- LPStatus
- Defines the User Learning Path attempt status entity.
Namespace
Drupal\opigno_learning_path\EntityCode
public static function getCertificateExpirationMessage($gid, $uid, $type = NULL) {
  $expire_text = '';
  if (!empty($type)) {
    switch ($type) {
      case 'valid':
        $expire_text = t('Valid until') . ' ';
        break;
      case 'expired':
        $expire_text = t('Expired on') . ' ';
        break;
    }
  }
  $date_formatter = \Drupal::service('date.formatter');
  $expire = LPStatus::getCertificateExpireTimestamp($gid, $uid);
  return !empty($expire) ? $expire_text . $date_formatter
    ->format($expire, 'custom', 'F d, Y') : '';
}