Skip to content

Commit

Permalink
Added new Remover it is remove should be used in pair with Thumbnaile…
Browse files Browse the repository at this point in the history
…r decorator.
  • Loading branch information
spalax committed Jul 25, 2013
1 parent 0df1857 commit b5d0816
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Zf2FileUploader/Resource/Remover/ThumbnailsRemover.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
namespace Zf2FileUploader\Resource\Remover;

use Zf2FileUploader\Resource\ResourceRemovableInterface;

class ThumbnailsRemover implements RemoverInterface
{
/**
* @param ResourceRemovableInterface $resource
* @return boolean
*/
public function remove(ResourceRemovableInterface $resource)
{
$result = true;

$directory = new \DirectoryIterator(dirname($resource->getPath()));
/* @var $file \DirectoryIterator */
foreach ($directory as $file) {
if ($file->isDir()) continue;
if (preg_match('/.*\_[0-9]+x[0-9]+.*/', $file->getBasename())) {
if (!unlink($file->getRealPath())) {
$result = false;
}
}
}

return $result;
}
}

0 comments on commit b5d0816

Please sign in to comment.