Use content array instead of just id
Makes it easier when additional properties are needed. Also, don't try to translate PHP exception messages. h5p/h5p-moodle-plugin#112JI-92-path-fix
parent
c88c049438
commit
fd34af6964
|
@ -53,11 +53,11 @@ class H5PDefaultStorage implements \H5PFileStorage {
|
|||
*
|
||||
* @param string $source
|
||||
* Path on file system to content directory.
|
||||
* @param int $id
|
||||
* What makes this content unique.
|
||||
* @param array $content
|
||||
* Content properties
|
||||
*/
|
||||
public function saveContent($source, $id) {
|
||||
$dest = "{$this->path}/content/{$id}";
|
||||
public function saveContent($source, $content) {
|
||||
$dest = "{$this->path}/content/{$content['id']}";
|
||||
|
||||
// Remove any old content
|
||||
\H5PCore::deleteFileTree($dest);
|
||||
|
@ -68,11 +68,11 @@ class H5PDefaultStorage implements \H5PFileStorage {
|
|||
/**
|
||||
* Remove content folder.
|
||||
*
|
||||
* @param int $id
|
||||
* Content identifier
|
||||
* @param array $content
|
||||
* Content properties
|
||||
*/
|
||||
public function deleteContent($id) {
|
||||
\H5PCore::deleteFileTree("{$this->path}/content/{$id}");
|
||||
public function deleteContent($content) {
|
||||
\H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,18 +22,18 @@ interface H5PFileStorage {
|
|||
*
|
||||
* @param string $source
|
||||
* Path on file system to content directory.
|
||||
* @param int $id
|
||||
* What makes this content unique.
|
||||
* @param array $content
|
||||
* Content properties
|
||||
*/
|
||||
public function saveContent($source, $id);
|
||||
public function saveContent($source, $content);
|
||||
|
||||
/**
|
||||
* Remove content folder.
|
||||
*
|
||||
* @param int $id
|
||||
* Content identifier
|
||||
* @param array $content
|
||||
* Content properties
|
||||
*/
|
||||
public function deleteContent($id);
|
||||
public function deleteContent($content);
|
||||
|
||||
/**
|
||||
* Creates a stored copy of the content folder.
|
||||
|
|
|
@ -1311,15 +1311,15 @@ class H5PStorage {
|
|||
if (isset($options['disable'])) {
|
||||
$content['disable'] = $options['disable'];
|
||||
}
|
||||
$contentId = $this->h5pC->saveContent($content, $contentMainId);
|
||||
$this->contentId = $contentId;
|
||||
$content['id'] = $this->h5pC->saveContent($content, $contentMainId);
|
||||
$this->contentId = $content['id'];
|
||||
|
||||
try {
|
||||
// Save content folder contents
|
||||
$this->h5pC->fs->saveContent($current_path, $contentId);
|
||||
$this->h5pC->fs->saveContent($current_path, $content);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->h5pF->setErrorMessage($this->h5pF->t($e->getMessage()));
|
||||
$this->h5pF->setErrorMessage($e->getMessage());
|
||||
}
|
||||
|
||||
// Remove temp content folder
|
||||
|
@ -1433,7 +1433,7 @@ class H5PStorage {
|
|||
* @param $content
|
||||
*/
|
||||
public function deletePackage($content) {
|
||||
$this->h5pC->fs->deleteContent($content['id']);
|
||||
$this->h5pC->fs->deleteContent($content);
|
||||
$this->h5pC->fs->deleteExport(($content['slug'] ? $content['slug'] . '-' : '') . $content['id'] . '.h5p');
|
||||
$this->h5pF->deleteContentData($content['id']);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue