mirror of
https://github.com/flextype/flextype.git
synced 2025-08-09 14:46:53 +02:00
refactor(media): code cleanup
This commit is contained in:
@@ -269,7 +269,6 @@ class MediaFiles
|
||||
$result = [];
|
||||
|
||||
if (Filesystem::has($this->flextype['media_files_meta']->getFileMetaLocation($path))) {
|
||||
|
||||
$result = $this->flextype['yaml']->decode(Filesystem::read($this->flextype['media_files_meta']->getFileMetaLocation($path)));
|
||||
|
||||
$result['filename'] = pathinfo(str_replace('/.meta', '', $this->flextype['media_files_meta']->getFileMetaLocation($path)))['filename'];
|
||||
@@ -354,12 +353,8 @@ class MediaFiles
|
||||
*/
|
||||
public function delete(string $id) : bool
|
||||
{
|
||||
if (Filesystem::delete($this->getFileLocation($id)) &&
|
||||
Filesystem::delete($this->flextype['media_files_meta']->getFileMetaLocation($id))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Filesystem::delete($this->getFileLocation($id)) &&
|
||||
Filesystem::delete($this->flextype['media_files_meta']->getFileMetaLocation($id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,12 +368,8 @@ class MediaFiles
|
||||
*/
|
||||
public function has(string $id) : bool
|
||||
{
|
||||
if (Filesystem::has($this->getFileLocation($id)) &&
|
||||
Filesystem::has($this->flextype['media_files_meta']->getFileMetaLocation($id))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Filesystem::has($this->getFileLocation($id)) &&
|
||||
Filesystem::has($this->flextype['media_files_meta']->getFileMetaLocation($id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -37,7 +37,7 @@ class MediaFolders
|
||||
/**
|
||||
* Fetch folders(s)
|
||||
*
|
||||
* @param string $path The path of directory to list.
|
||||
* @param string $path The path of directory to list.
|
||||
* @param bool $collection Set `true` if collection of folders need to be fetched.
|
||||
*
|
||||
* @return array A list of file(s) metadata.
|
||||
@@ -149,12 +149,8 @@ class MediaFolders
|
||||
*/
|
||||
public function delete(string $id) : bool
|
||||
{
|
||||
if (Filesystem::deleteDir($this->getDirLocation($id)) &&
|
||||
Filesystem::deleteDir($this->flextype['media_folders_meta']->getDirMetaLocation($id))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Filesystem::deleteDir($this->getDirLocation($id)) &&
|
||||
Filesystem::deleteDir($this->flextype['media_folders_meta']->getDirMetaLocation($id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user