diff --git a/h5p.api.php b/h5p.api.php index ba3f1ca6c04908262df25455e77aa9d043a60acd..9737164c509d4a9891fec77c81290aa1af61f968 100644 --- a/h5p.api.php +++ b/h5p.api.php @@ -28,9 +28,9 @@ function hook_h5p_semantics_alter(&$semantics, $machine_name, $major_version, $m /** * Alter an H5Ps parameters - * + * * May be used to alter the content itself or the behaviour of the H5P - * + * * @param type $filtered * json object */ @@ -52,7 +52,7 @@ function hook_h5p_filtered_params_alter(&$filtered) { /** * Add styles to H5Ps - * + * * @param array $styles * Array of objects with properties path and version. Version is on the form * ?ver=1.0.2 and is used as a cache buster @@ -75,7 +75,7 @@ function hook_h5p_styles_alter(&$styles, $libraries, $mode) { /** * Add scripts to h5ps - * + * * @param array $scripts * Array of objects with properties path and version. Version is on the form * ?ver=1.0.2 and is used as a cache buster @@ -96,4 +96,17 @@ function hook_h5p_scripts_alter(&$scripts, $libraries, $mode) { } } +/** + * Hook is invoked whenever an H5P library has been installed/updated. It is created + * to be able to run other actions, not to alter input data. + * + * @param array $libraryData + * This associative array contains everything found in library.json + * @param boolean $isNew + * If this is a new library, this will be TRUE, otherwise FALSE + */ +function hook_h5p_library_installed($libraryData, $isNew) { + $machineName = $libraryData['machineName']; +} + ?> diff --git a/h5p.classes.inc b/h5p.classes.inc index eb643d776fe7b8e740144b96724b058e492927c6..5cb68256f4193d0f2b3aebd82f5746fe8f67513a 100644 --- a/h5p.classes.inc +++ b/h5p.classes.inc @@ -335,6 +335,12 @@ class H5PDrupal implements H5PFrameworkInterface { $libraryData['majorVersion'] . '.' . $libraryData['minorVersion'] ); + // Invoke h5p_library_installed hook for each library that has + // been installed + if (sizeof(module_implements('h5p_library_installed')) > 0) { + module_invoke_all('h5p_library_installed', $libraryData, $new); + } + db_delete('h5p_libraries_languages') ->condition('library_id', $libraryData['libraryId']) ->execute();