0

Whenever I call this code, a warning is given:

Warning: rmdir(/path/to/assets/photo-albums/example): Directory not empty

The reason is quite obvious. there are still pictures in there. In Doctrine they will be removed by cacade configuration.

Is it possible to tell Gaufrette to ignore directory contents, and just remove everything at once without needing to loop over the albums photo's?

...
use Knp\Bundle\GaufretteBundle\Filesystem;

/**
 * @var Filesystem
 */
private $_photoAssetFilesystem;

public function RemovePhotoAlbum(PhotoAlbum $photoAlbum) : RedirectResponse
{
    ...

    $this->_photoAssetFilesystem->delete($photoAlbum->getDir());

    ...
}

Note: $photoAssetFilesystem is injected into this controller with DI

murtho
  • 991
  • 1
  • 17
  • 38
  • 1
    Gaufrette is a filesystem abstraction, so it has to be limited in terms of adapter implementation. Local adapter calls [rmdir](http://php.net/manual/en/function.rmdir.php), so it requires explicit delete call on directory contents. – Mateusz Sip Jun 03 '17 at 12:56
  • that's what I was afraid of :-( – murtho Jun 03 '17 at 13:26

0 Answers0