You are here

public static function OpignoModuleBadges::opignoModuleGetBadges in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/OpignoModuleBadges.php \Drupal\opigno_module\OpignoModuleBadges::opignoModuleGetBadges()

Returns badges count for module/course in a training.

Parameters

int $uid: User ID.

int $gid: Training ID.

string $typology: Course or Module string.

int $entity_id: Module/Course ID.

Return value

mixed Badges count or FALSE if empty.

1 call to OpignoModuleBadges::opignoModuleGetBadges()
OpignoModuleBadges::opignoModuleSaveBadge in src/OpignoModuleBadges.php
Saves/updates badges count.

File

src/OpignoModuleBadges.php, line 71

Class

OpignoModuleBadges
Class OpignoModuleBadges.

Namespace

Drupal\opigno_module

Code

public static function opignoModuleGetBadges($uid, $gid, $typology, $entity_id) {

  // Get existing badge count.
  $query = \Drupal::database()
    ->select('opigno_module_badges', 'mb')
    ->fields('mb', [
    'badges',
  ])
    ->condition('uid', $uid)
    ->condition('gid', $gid)
    ->condition('typology', $typology)
    ->condition('entity_id', $entity_id);
  $result = $query
    ->execute()
    ->fetchField();
  return $result ? $result : FALSE;
}