Fix dependency checking
parent
b383ae0124
commit
d51e6e8d01
|
@ -414,13 +414,18 @@ class H5PValidator {
|
||||||
$this->h5pC->mainJsonData = $mainH5pData;
|
$this->h5pC->mainJsonData = $mainH5pData;
|
||||||
$this->h5pC->contentJsonData = $contentJsonData;
|
$this->h5pC->contentJsonData = $contentJsonData;
|
||||||
|
|
||||||
$libraries['mainH5pData'] = $mainH5pData;
|
$libraries['mainH5pData'] = $mainH5pData; // Check for the dependencies in h5p.json as well as in the libraries
|
||||||
$missingLibraries = $this->getMissingLibraries($libraries);
|
$missingLibraries = $this->getMissingLibraries($libraries);
|
||||||
foreach ($missingLibraries as $missing) {
|
foreach ($missingLibraries as $missing) {
|
||||||
if ($this->h5pF->getLibraryId($missing['machineName'], $missing['majorVersion'], $missing['minorVersion'])) {
|
if ($this->h5pF->getLibraryId($missing['machineName'], $missing['majorVersion'], $missing['minorVersion'])) {
|
||||||
unset($missingLibraries[$missing['machineName']]);
|
unset($missingLibraries[$missing['machineName']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!empty($missingLibraries)) {
|
||||||
|
foreach ($missingLibraries as $library) {
|
||||||
|
$this->h5pF->setErrorMessage($this->h5pF->t('Missing required library @library', array('@library' => $this->h5pC->libraryToString($library))));
|
||||||
|
}
|
||||||
|
}
|
||||||
$valid = empty($missingLibraries) && $valid;
|
$valid = empty($missingLibraries) && $valid;
|
||||||
}
|
}
|
||||||
if (!$valid) {
|
if (!$valid) {
|
||||||
|
@ -442,13 +447,13 @@ class H5PValidator {
|
||||||
$missing = array();
|
$missing = array();
|
||||||
foreach ($libraries as $library) {
|
foreach ($libraries as $library) {
|
||||||
if (isset($library['preloadedDependencies'])) {
|
if (isset($library['preloadedDependencies'])) {
|
||||||
array_merge($missing, $this->getMissingDependencies($library['preloadedDependencies'], $libraries));
|
$missing = array_merge($missing, $this->getMissingDependencies($library['preloadedDependencies'], $libraries));
|
||||||
}
|
}
|
||||||
if (isset($library['dynamicDependencies'])) {
|
if (isset($library['dynamicDependencies'])) {
|
||||||
array_merge($missing, $this->getMissingDependencies($library['dynamicDependencies'], $libraries));
|
$missing = array_merge($missing, $this->getMissingDependencies($library['dynamicDependencies'], $libraries));
|
||||||
}
|
}
|
||||||
if (isset($library['editorDependencies'])) {
|
if (isset($library['editorDependencies'])) {
|
||||||
array_merge($missing, $this->getMissingDependencies($library['editorDependencies'], $libraries));
|
$missing = array_merge($missing, $this->getMissingDependencies($library['editorDependencies'], $libraries));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $missing;
|
return $missing;
|
||||||
|
@ -977,5 +982,17 @@ class H5PCore {
|
||||||
}
|
}
|
||||||
closedir($dir);
|
closedir($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes library data as string on the form {machineName} {majorVersion}.{minorVersion}
|
||||||
|
*
|
||||||
|
* @param array $library
|
||||||
|
* With keys machineName, majorVersion and minorVersion
|
||||||
|
* @return string
|
||||||
|
* On the form {machineName} {majorVersion}.{minorVersion}
|
||||||
|
*/
|
||||||
|
public function libraryToString($library) {
|
||||||
|
return $library['machineName'] . ' ' . $library['majorVersion'] . '.' . $library['minorVersion'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue