OPPG-425: Add hook_alter_h5p_semantics

Also re-adds getLibrarySemantics in core, used by the validator to fetch decoded semantics.
This function is also responsible for calling the hook.
namespaces
Frank Ronny Larsen 2013-07-09 15:13:09 +02:00
parent b5990bff8e
commit ab316a163c
1 changed files with 13 additions and 3 deletions

View File

@ -180,7 +180,6 @@ interface H5PFrameworkInterface {
*/ */
public function saveLibraryUsage($contentId, $librariesInUse); public function saveLibraryUsage($contentId, $librariesInUse);
/** /**
* Loads a library * Loads a library
* *
@ -193,6 +192,18 @@ interface H5PFrameworkInterface {
*/ */
public function loadLibrary($machineName, $majorVersion, $minorVersion); public function loadLibrary($machineName, $majorVersion, $minorVersion);
/**
* Loads and decodes library semantics.
*
* @param string $machineName
* @param int $majorVersion
* @param int $minorVersion
* @return array|FALSE
* Array representing the library with dependency descriptions
* FALSE if the library doesn't exist
*/
public function getLibrarySemantics($machineName, $majorVersion, $minorVersion);
/** /**
* Delete all dependencies belonging to given library * Delete all dependencies belonging to given library
* *
@ -1398,8 +1409,7 @@ class H5PContentValidator {
} }
else { else {
$libspec = $this->h5pC->libraryFromString($value->library); $libspec = $this->h5pC->libraryFromString($value->library);
$library = $this->h5pF->loadLibrary($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']); $librarySemantics = $this->h5pF->getLibrarySemantics($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']);
$librarySemantics = json_decode($library['semantics']);
$semanticsCache[$value->library] = $librarySemantics; $semanticsCache[$value->library] = $librarySemantics;
} }
$this->validateBySemantics($value->params, $librarySemantics); $this->validateBySemantics($value->params, $librarySemantics);