public deleteImageVariations ( $user, $imageIdentifier, $width = null ) |
public function deleteImageVariations($user, $imageIdentifier, $width = null)
{
// If width is specified, delete only the specific image
if ($width !== null) {
return unlink($this->getImagePath($user, $imageIdentifier, $width, true));
}
// If width is not specified, delete every variation, then the folder
$variationsPath = $this->getImagePath($user, $imageIdentifier);
if (!is_dir($variationsPath)) {
return false;
}
array_map('unlink', glob($variationsPath . '/*'));
return rmdir($variationsPath);
}
/** * @covers Imbo\EventListener\ImageVariations\Storage\Filesystem::deleteImageVariations */ public function testDoesNotThrowWhenDeletingNonExistantVariation() { $dir = 'basedir'; vfsStream::setup($dir); $adapter = new Filesystem(['dataDir' => vfsStream::url($dir)]); $this->assertFalse($adapter->deleteImageVariations('pub', 'img')); }