Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
core_h5p\core Class Reference

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

Inheritance diagram for core_h5p\core:

Public Member Functions

 __construct (H5PFrameworkInterface $framework, $path, string $url, string $language='en', bool $export=false)
 Constructor for core_h5p/core.
 
 fetch_content_type (array $library)
 Given an H5P content type machine name, fetch and install the required library from the official H5P repository.
 
 fetch_latest_content_types ()
 Fetch and install the latest H5P content types libraries from the official H5P repository.
 
 get_api_endpoint (?string $library=null, string $endpoint='content')
 Get H5P endpoints.
 
 get_dependency_roots (int $id)
 Get the paths to the content dependencies.
 
 get_latest_content_types ()
 Get the latest version of the H5P content types available in the official repository.
 
 get_site_uuid ()
 Get the site UUID.
 
 getLibraryId ($library, $libString=null)
 Small helper for getting the library's ID.
 
 is_required_core_api ($coreapi)
 Checks that the required H5P core API version or higher is installed.
 

Static Public Member Functions

static get_scripts ()
 Get the list of JS scripts to include on the page.
 
static record_to_string (stdClass $record, bool $foldername=false)
 Get the library string from a DB library record.
 

Protected Member Functions

 find_library (array $dependency)
 Get a particular dependency library.
 
 getDependencyPath (array $dependency)
 Get the path to the dependency.
 

Protected Attributes

array $libraries
 The array containing all the present libraries.
 

Detailed Description

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

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_h5p\core::__construct ( H5PFrameworkInterface $framework,
$path,
string $url,
string $language = 'en',
bool $export = false )

Constructor for core_h5p/core.

Parameters
H5PFrameworkInterface$frameworkThe frameworks implementation of the H5PFrameworkInterface
string | H5PFileStorage$pathThe H5P file storage directory or class
string$urlThe URL to the file storage directory
string$languageThe language code. Defaults to english
boolean$exportWhether export is enabled

Member Function Documentation

◆ fetch_content_type()

core_h5p\core::fetch_content_type ( array $library)

Given an H5P content type machine name, fetch and install the required library from the official H5P repository.

Parameters
array$libraryLibrary machineName, majorversion and minorversion.
Return values
int|nullReturns the id of the content type library installed, null otherwise.

◆ fetch_latest_content_types()

core_h5p\core::fetch_latest_content_types ( )

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 values
stdClass

◆ find_library()

core_h5p\core::find_library ( array $dependency)
protected

Get a particular dependency library.

Parameters
array$dependencyAn array containing information of the dependency library
Return values
stdClass|nullThe library object if the library dependency exists, null otherwise

◆ get_api_endpoint()

core_h5p\core::get_api_endpoint ( ?string $library = null,
string $endpoint = 'content' )

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.

Parameters
string | null$libraryThe machineName of the library whose endpoint is requested.
string$endpointThe endpoint required. Valid values: "site", "content".
Return values
moodle_urlThe endpoint moodle_url object.

◆ get_dependency_roots()

core_h5p\core::get_dependency_roots ( int $id)

Get the paths to the content dependencies.

Parameters
int$idThe H5P content ID
Return values
arrayAn array containing the path of each content dependency

◆ get_latest_content_types()

core_h5p\core::get_latest_content_types ( )

Get the latest version of the H5P content types available in the official repository.

Return values
stdClassAn object with 2 properties:
  • string error: error message when there is any problem, empty otherwise
  • array contentTypes: an object for each H5P content type with its information

◆ get_scripts()

static core_h5p\core::get_scripts ( )
static

Get the list of JS scripts to include on the page.

Return values
arrayThe array containg urls of the core JavaScript files

◆ get_site_uuid()

core_h5p\core::get_site_uuid ( )

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.

◆ getDependencyPath()

core_h5p\core::getDependencyPath ( array $dependency)
protected

Get the path to the dependency.

Parameters
array$dependencyAn array containing the information of the requested dependency library
Return values
stringThe path to the dependency library

◆ getLibraryId()

core_h5p\core::getLibraryId ( $library,
$libString = null )

Small helper for getting the library's ID.

This method is rewritten to use MUC (instead of an static variable which causes some problems with PHPUnit).

Parameters
array$library
string$libString
Return values
intIdentifier, or FALSE if non-existent

◆ is_required_core_api()

core_h5p\core::is_required_core_api ( $coreapi)

Checks that the required H5P core API version or higher is installed.

Parameters
stdClass$coreapiObject with properties major and minor for the core API version required.
Return values
boolTrue if the required H5P core API version is installed. False if not.

◆ record_to_string()

static core_h5p\core::record_to_string ( stdClass $record,
bool $foldername = false )
static

Get the library string from a DB library record.

Parameters
stdClass$recordThe DB library record.
bool$foldernameIf true, use hyphen instead of space in returned string.
Return values
stringThe string name on the form {machineName} {majorVersion}.{minorVersion}.

The documentation for this class was generated from the following file: