Example #1
0
 /**
  * Deletes an image
  * Wrapped into this method to avoid duplication
  * 
  * @param string $id Image id
  * @param string $categoryId Can be provided to omit a look up
  * @return boolean
  */
 private function delete($id, $categoryId = null)
 {
     if (is_null($categoryId)) {
         // Grab a category id for uploader instance
         $categoryId = $this->imageMapper->fetchCategoryIdById($id);
     }
     if ($categoryId) {
         if ($this->imageMapper->deleteById($id) && $this->getUploader($categoryId)->delete($id)) {
             return true;
         } else {
             // Failed to remove a file
             return false;
         }
     } else {
         // Invalid id supplied
         return false;
     }
 }