You are here

public static function LearningPathAccess::deleteUserStatus in Opigno Learning path 8

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

Deletes Learning Path group user status.

2 calls to LearningPathAccess::deleteUserStatus()
LearningPathAccess::setLearningPathCourseMember in src/LearningPathAccess.php
Sets Learning Path content course member.
opigno_learning_path_entity_delete in ./opigno_learning_path.module
Implements hook_entity_delete().

File

src/LearningPathAccess.php, line 346

Class

LearningPathAccess
Class LearningPathAccess.

Namespace

Drupal\opigno_learning_path

Code

public static function deleteUserStatus(EntityInterface $membership) {
  $query = \Drupal::database()
    ->delete('opigno_learning_path_group_user_status')
    ->condition('mid', $membership
    ->id());
  $result = $query
    ->execute();
  if ($result) {

    /** @var \Drupal\group\Entity\GroupContentInterface $membership */
    $entity = $membership
      ->getEntity();
    $group = $membership
      ->getGroup();
    if (isset($entity) && isset($group) && $group
      ->bundle() == 'learning_path') {
      $uid = $entity
        ->id();
      $token = \Drupal::moduleHandler()
        ->moduleExists('token');
      LearningPathAccess::notifyUsersByMail($group, $uid, NULL, $token);
    }
  }
}