You are here

public static function LPStatus::removeCertificateExpiration in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Entity/LPStatus.php \Drupal\opigno_learning_path\Entity\LPStatus::removeCertificateExpiration()

Removes training certificate expire timestamp.

Parameters

int $gid: Group ID.

int|null $uid: User ID.

1 call to LPStatus::removeCertificateExpiration()
opigno_learning_path_entity_delete in ./opigno_learning_path.module
Implements hook_entity_delete().

File

src/Entity/LPStatus.php, line 438

Class

LPStatus
Defines the User Learning Path attempt status entity.

Namespace

Drupal\opigno_learning_path\Entity

Code

public static function removeCertificateExpiration($gid, $uid = NULL) {
  $db_connection = \Drupal::service('database');
  try {
    $query = $db_connection
      ->delete('user_lp_status_expire');
    $query
      ->condition('gid', $gid);
    if ($uid) {
      $query
        ->condition('uid', $uid);
    }
    $query
      ->execute();
  } catch (\Exception $e) {
    \Drupal::logger('opigno_learning_path')
      ->error($e
      ->getMessage());
    \Drupal::messenger()
      ->addMessage($e
      ->getMessage(), 'error');
  }
}