You are here

public static function ExternalPackageController::getH5PLibraryData in Opigno module 8

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

Returns library data.

Parameters

string $machine_name: Library machine name.

Return value

array|mixed H5P library data.

1 call to ExternalPackageController::getH5PLibraryData()
ExternalPackageController::createH5pCoursePresentationPackage in src/Controller/ExternalPackageController.php
Creates H5P content package file.

File

src/Controller/ExternalPackageController.php, line 585

Class

ExternalPackageController
Class ActivitiesBrowserController.

Namespace

Drupal\opigno_module\Controller

Code

public static function getH5PLibraryData($machine_name) {
  $db_connection = \Drupal::service('database');

  // Get new library id with highest version.
  $query = $db_connection
    ->select('h5p_libraries', 'l')
    ->fields('l', [
    'library_id',
    'machine_name',
    'major_version',
    'minor_version',
  ])
    ->orderBy('major_version', 'DESC')
    ->orderBy('minor_version', 'DESC')
    ->condition('machine_name', $machine_name);
  $result = $query
    ->execute()
    ->fetchAllAssoc('library_id');
  if ($result) {
    return reset($result);
  }
  return [];
}