FEATURE #1551: add deleting directory after page deletion.

This commit is contained in:
Michal Kváček
2016-04-11 01:34:01 +02:00
parent a48bed04b1
commit 098ea3e7b1
+30
View File
@@ -207,4 +207,34 @@ class Gallery implements AppHandler
Storage::put(self::CONFIG_FILENAME, $directory->id);
}
/**
* Method called right after content page is marked as deleted
*
* This method is supposed to clean after "deleted" page.
*
* @param Content $content
*
* @return mixed
*/
public static function delete(Content $content)
{
// try to convert module_settings into something more accessible
if (is_string($content->module_settings)) {
$content->module_settings = json_decode($content->module_settings);
}
// get directory id
$directoryId = $content->module_settings->directoryId;
$directory = Directory::find($directoryId);
// check if gallery exists
if (!$directory) {
return;
}
// delete directory used as photogallery
$directory->delete();
}
}