mirror of
https://github.com/flextype/flextype.git
synced 2025-08-08 06:06:45 +02:00
feat(media): add method has() for Media API Folders #534
This commit is contained in:
@@ -165,7 +165,7 @@ class MediaFolders
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete dir
|
||||
* Delete folder
|
||||
*
|
||||
* @param string $id Unique identifier of the file.
|
||||
*
|
||||
@@ -179,6 +179,21 @@ class MediaFolders
|
||||
filesystem()->directory(flextype('media')->folders()->meta()->getDirectoryMetaLocation($id))->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a folder exists.
|
||||
*
|
||||
* @param string $id Unique identifier of the folder.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function has(string $id): bool
|
||||
{
|
||||
return filesystem()->directory($this->getDirectoryLocation($id))->exists() &&
|
||||
filesystem()->directory(flextype('media')->folders()->meta()->getDirectoryMetaLocation($id))->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get files directory location
|
||||
*
|
||||
|
@@ -35,6 +35,13 @@ test('test copy() method', function () {
|
||||
$this->assertTrue(flextype('media')->folders()->copy('foo', 'bar'));
|
||||
});
|
||||
|
||||
|
||||
test('test has() method', function () {
|
||||
$this->assertTrue(flextype('media')->folders()->create('foo'));
|
||||
$this->assertTrue(flextype('media')->folders()->has('foo'));
|
||||
$this->assertFalse(flextype('media')->folders()->has('bar'));
|
||||
});
|
||||
|
||||
test('test delete() method', function () {
|
||||
$this->assertTrue(flextype('media')->folders()->create('foo'));
|
||||
$this->assertTrue(flextype('media')->folders()->delete('foo'));
|
||||
|
Reference in New Issue
Block a user