diff --git a/h5p/classes/core.php b/h5p/classes/core.php
index 206f47cf3c6..37021611473 100644
--- a/h5p/classes/core.php
+++ b/h5p/classes/core.php
@@ -15,7 +15,7 @@
// along with Moodle. If not, see .
/**
- * H5P player class.
+ * H5P core class.
*
* @package core_h5p
* @copyright 2019 Sara Arjona
@@ -32,7 +32,7 @@ use moodle_url;
defined('MOODLE_INTERNAL') || die();
/**
- * H5P player class, for displaying any local H5P content.
+ * H5P core class, containing functions and storage shared by the other H5P classes.
*
* @package core_h5p
* @copyright 2019 Sara Arjona
@@ -40,6 +40,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class core extends \H5PCore {
+ /** @var array The array containing all the present libraries */
protected $libraries;
/**
@@ -60,12 +61,24 @@ class core extends \H5PCore {
$this->aggregateAssets = true;
}
+ /**
+ * Get the path to the dependency.
+ *
+ * @param array $dependency An array containing the information of the requested dependency library
+ * @return string The path to the dependency library
+ */
protected function getDependencyPath(array $dependency): string {
$library = $this->find_library($dependency);
return "libraries/{$library->id}/{$library->machinename}-{$library->majorversion}.{$library->minorversion}";
}
+ /**
+ * Get the paths to the content dependencies.
+ *
+ * @param int $id The H5P content ID
+ * @return array An array containing the path of each content dependency
+ */
public function get_dependency_roots(int $id): array {
$roots = [];
$dependencies = $this->h5pF->loadContentDependencies($id);
@@ -85,7 +98,13 @@ class core extends \H5PCore {
return $roots;
}
- protected function find_library($dependency): \stdClass {
+ /**
+ * Get a particular dependency library.
+ *
+ * @param array $dependency An array containing information of the dependency library
+ * @return stdClass|null The library object if the library dependency exists, null otherwise
+ */
+ protected function find_library(array $dependency): ?\stdClass {
global $DB;
if (null === $this->libraries) {
$this->libraries = $DB->get_records('h5p_libraries');
@@ -116,6 +135,11 @@ class core extends \H5PCore {
return null;
}
+ /**
+ * Get core JavaScript files.
+ *
+ * @return array The array containg urls of the core JavaScript files
+ */
public static function get_scripts(): array {
global $CFG;
$cachebuster = '?ver='.$CFG->jsrev;
diff --git a/h5p/classes/factory.php b/h5p/classes/factory.php
index d63bfc2c502..52c8cc09679 100644
--- a/h5p/classes/factory.php
+++ b/h5p/classes/factory.php
@@ -86,14 +86,14 @@ class factory {
*/
public function get_core(): core {
if (null === $this->core) {
- $fs = new \core_h5p\file_storage();
- $language = \core_h5p\framework::get_language();
- $context = \context_system::instance();
+ $fs = new \core_h5p\file_storage();
+ $language = \core_h5p\framework::get_language();
+ $context = \context_system::instance();
- $url = \moodle_url::make_pluginfile_url($context->id, 'core_h5p', '', null,
- '', '')->out();
+ $url = \moodle_url::make_pluginfile_url($context->id, 'core_h5p', '', null,
+ '', '')->out();
- $this->core = new core($this->get_framework(), $fs, $url, $language, true);
+ $this->core = new core($this->get_framework(), $fs, $url, $language, true);
}
return $this->core;