/**
  * Delete an image
  *
  * @param array $imageInfo
  *      integer id
  *      string name
  *      string description
  *      integer category_id
  *      string image
  *      integer created
  * @throws \MiniPhotoGallery\Exception\MiniPhotoGalleryException
  * @return boolean|string
  */
 public function deleteImage(array $imageInfo)
 {
     try {
         $this->adapter->getDriver()->getConnection()->beginTransaction();
         $delete = $this->delete()->from('miniphotogallery_image')->where(['id' => $imageInfo['id']]);
         $statement = $this->prepareStatementForSqlObject($delete);
         $result = $statement->execute();
         // delete an image
         if (true !== ($imageDeleteResult = $this->deleteMiniPhotoGalleryImage($imageInfo['image']))) {
             throw new MiniPhotoGalleryException('Image deleting failed');
         }
         $this->adapter->getDriver()->getConnection()->commit();
     } catch (Exception $e) {
         $this->adapter->getDriver()->getConnection()->rollback();
         ApplicationErrorLogger::log($e);
         return $e->getMessage();
     }
     $result = $result->count() ? true : false;
     // fire the delete image event
     if ($result) {
         MiniPhotoGalleryEvent::fireDeleteImageEvent($imageInfo['id']);
     }
     return $result;
 }
 /**
  * Add a new category
  *
  * @param array $categoryInfo
  *      string name
  * @return boolean|string
  */
 public function addCategory(array $categoryInfo)
 {
     try {
         $this->adapter->getDriver()->getConnection()->beginTransaction();
         $insert = $this->insert()->into('miniphotogallery_category')->values(array_merge($categoryInfo, ['language' => $this->getCurrentLanguage()]));
         $statement = $this->prepareStatementForSqlObject($insert);
         $statement->execute();
         $insertId = $this->adapter->getDriver()->getLastGeneratedValue();
         $this->adapter->getDriver()->getConnection()->commit();
     } catch (Exception $e) {
         $this->adapter->getDriver()->getConnection()->rollback();
         ApplicationErrorLogger::log($e);
         return $e->getMessage();
     }
     // fire the add category event
     MiniPhotoGalleryEvent::fireAddCategoryEvent($insertId);
     return true;
 }