From ab316a163c0109f7492a29a1a98d3ea27883d2bb Mon Sep 17 00:00:00 2001 From: Frank Ronny Larsen Date: Tue, 9 Jul 2013 15:13:09 +0200 Subject: [PATCH] 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. --- h5p.classes.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 5c4d17e..99e54fa 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -180,7 +180,6 @@ interface H5PFrameworkInterface { */ public function saveLibraryUsage($contentId, $librariesInUse); - /** * Loads a library * @@ -193,6 +192,18 @@ interface H5PFrameworkInterface { */ 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 * @@ -1398,8 +1409,7 @@ class H5PContentValidator { } else { $libspec = $this->h5pC->libraryFromString($value->library); - $library = $this->h5pF->loadLibrary($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']); - $librarySemantics = json_decode($library['semantics']); + $librarySemantics = $this->h5pF->getLibrarySemantics($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']); $semanticsCache[$value->library] = $librarySemantics; } $this->validateBySemantics($value->params, $librarySemantics);