Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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. More...
 
 fetch_content_type (array $library)
 Given an H5P content type machine name, fetch and install the required library from the official H5P repository. More...
 
 fetch_latest_content_types ()
 Fetch and install the latest H5P content types libraries from the official H5P repository. More...
 
 get_api_endpoint (?string $library)
 Get H5P endpoints. More...
 
 get_dependency_roots (int $id)
 Get the paths to the content dependencies. More...
 
 get_latest_content_types ()
 Get the latest version of the H5P content types available in the official repository. More...
 
 is_required_core_api ($coreapi)
 Checks that the required H5P core API version or higher is installed. More...
 

Static Public Member Functions

static get_scripts ()
 Get core JavaScript files. More...
 

Protected Member Functions

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

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)

Get H5P endpoints.

If $library is null, moodle_url is the endpoint of the latest version of the H5P content types. If library is the machine name of a content type, moodle_url is the endpoint to download the content type.

Parameters
string | null$libraryThe machineName of the library whose endpoint is requested.
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 core JavaScript files.

Return values
arrayThe array containg urls of the core JavaScript files

◆ 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

◆ 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.

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