public static function deleteEntityImages(Entity $object)
 {
     $class = strtolower(join('', array_slice(explode('\\', get_class($object)), -1)));
     // Get existing images in DB
     $image_collection = new ImageEntityRepository();
     $image_collection->setWhereItemType($class);
     $image_collection->setWhereItemId($object->getId());
     return $image_collection->deleteObjectCollection();
 }
Example #2
0
 /**
  * @param ImageEntityRepository $images
  * @return $this
  */
 public function setImages(ImageEntityRepository $images)
 {
     $images->addOrderByField();
     $image_data = [];
     foreach ($images->getAsArrayOfObjectData() as $image) {
         $image_data[$image['item_id']][] = $image['image'];
     }
     $this->images = $image_data;
     return $this;
 }