Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]

H5P core class.

Copyright: 2019 Sara Arjona <sara@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 396 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: core  - X-Ref

H5P core class, containing functions and storage shared by the other H5P classes.

__construct(H5PFrameworkInterface $framework, $path, string $url, string $language = 'en',bool $export = false)   X-Ref
Constructor for core_h5p/core.

param: H5PFrameworkInterface $framework The frameworks implementation of the H5PFrameworkInterface
param: string|H5PFileStorage $path The H5P file storage directory or class
param: string $url The URL to the file storage directory
param: string $language The language code. Defaults to english
param: boolean $export Whether export is enabled

getDependencyPath(array $dependency)   X-Ref
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

get_dependency_roots(int $id)   X-Ref
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

find_library(array $dependency)   X-Ref
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

get_scripts()   X-Ref
Get the list of JS scripts to include on the page.

return: array The array containg urls of the core JavaScript files

fetch_latest_content_types()   X-Ref
Fetch and install the latest H5P content types libraries from the official H5P repository.
If the latest version of a content type library is present in the system, nothing is done for that content type.

return: stdClass

fetch_content_type(array $library)   X-Ref
Given an H5P content type machine name, fetch and install the required library from the official H5P repository.

param: array $library Library machineName, majorversion and minorversion.
return: int|null Returns the id of the content type library installed, null otherwise.

get_api_endpoint(?string $library = null, string $endpoint = 'content')   X-Ref
Get H5P endpoints.

If $endpoint = 'content' and $library is null, moodle_url is the endpoint of the latest version of the H5P content
types; however, if $library is the machine name of a content type, moodle_url is the endpoint to download the content type.
The SITES endpoint ($endpoint = 'site') may be use to get a site UUID or send site data.

param: string|null $library The machineName of the library whose endpoint is requested.
param: string $endpoint The endpoint required. Valid values: "site", "content".
return: moodle_url The endpoint moodle_url object.

get_latest_content_types()   X-Ref
Get the latest version of the H5P content types available in the official repository.

return: stdClass An object with 2 properties:

get_site_uuid()   X-Ref
Get the site UUID. If site UUID is not defined, try to register the site.

return $string The site UUID, null if it is not set.

register_site()   X-Ref
Get H5P generated site UUID.

return ?string Returns H5P generated site UUID, null if can't get it.

is_required_core_api($coreapi)   X-Ref
Checks that the required H5P core API version or higher is installed.

param: stdClass $coreapi Object with properties major and minor for the core API version required.
return: bool True if the required H5P core API version is installed. False if not.

record_to_string(stdClass $record, bool $foldername = false)   X-Ref
Get the library string from a DB library record.

param: stdClass $record The DB library record.
param: bool $foldername If true, use hyphen instead of space in returned string.
return: string The string name on the form {machineName} {majorVersion}.{minorVersion}.