Merge branch 'module_gallery' into dev
This commit is contained in:
@@ -83,15 +83,13 @@ class Gallery implements AppHandler
|
|||||||
|
|
||||||
// create new directory for images
|
// create new directory for images
|
||||||
$directory = Directory::create([
|
$directory = Directory::create([
|
||||||
'name' => $request->title,
|
'name' => $content->id . '_' . $request->title,
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'parent_id' => $parentDirectoryId
|
'parent_id' => $parentDirectoryId
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// save id into module_config array
|
// save id into module_config array
|
||||||
$settings = [
|
$settings = ['directoryId' => $directory->id];
|
||||||
'directoryId' => $directory->id
|
|
||||||
];
|
|
||||||
|
|
||||||
// save settings
|
// save settings
|
||||||
$content->module_settings = json_encode($settings);
|
$content->module_settings = json_encode($settings);
|
||||||
@@ -209,4 +207,34 @@ class Gallery implements AppHandler
|
|||||||
|
|
||||||
Storage::put(self::CONFIG_FILENAME, $directory->id);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user