/**
  * @param mixed $id
  * @return ApiProblem|boolean
  */
 public function delete($id)
 {
     $renditions = $this->imageManager->getRenditions();
     $result = $this->imageManager->delete($id, CoreInterface::RENDITION_ORIGINAL);
     foreach ($renditions as $rendition => $options) {
         $deleteRendition = $this->imageManager->delete($id, $rendition);
         $result = $result || $deleteRendition;
     }
     if ($result) {
         return $result;
     }
     return new ApiProblem(404, 'Image not found');
 }
Exemplo n.º 2
0
 public function testServiceDelete()
 {
     $storage = $this->getMock('ImgMan\\Storage\\Adapter\\Mongo\\MongoAdapter');
     $storage->expects($this->any())->method('deleteImage')->will($this->returnValue(true));
     $adapter = $this->getMock('ImgMan\\Core\\Adapter\\ImagickAdapter');
     $pluginManager = $this->getMock('ImgMan\\Operation\\HelperPluginManager');
     /** @var $storage MongoAdapter */
     /** @var $pluginManager HelperPluginManager */
     /** @var $adapter ImagickAdapter */
     $service = new ImageService($storage, $pluginManager, $adapter);
     $this->assertTrue($service->delete('test/test/'));
 }