コード例 #1
0
ファイル: SettingService.php プロジェクト: JoshBour/karolina
 /**
  * @param $data
  * @param \Zend\Form\Form $form
  * @return bool
  */
 public function create($data, &$form)
 {
     $form->setData($data);
     if (!$form->isValid()) {
         return false;
     }
     if (!empty($data['setting']['aboutProfileImage']['name'])) {
         if (!($newName = FileUtilService::rename($data['setting']['aboutProfileImage'], 'images', null, "about-profile"))) {
             $this->message = $this->getTranslator()->translate($this->getVocabulary()["MESSAGE_SETTINGS_NOT_CREATED"]);
             return false;
         } else {
             FileUtilService::resize($newName, 'images', 400, null, 'png');
             FileUtilService::deleteFile(ROOT_PATH . '/images/' . $newName);
         }
     }
     if (!empty($data['setting']['homeImage']['name'])) {
         if (!FileUtilService::rename($data['setting']['homeImage'], 'images', null, "home-side-bg")) {
             $this->message = $this->getTranslator()->translate($this->getVocabulary()["MESSAGE_SETTINGS_NOT_CREATED"]);
             return false;
         }
     }
     if (!empty($data['setting']['aboutImage']['name'])) {
         if (!FileUtilService::rename($data['setting']['aboutImage'], 'images', null, "about-side-bg")) {
             $this->message = $this->getTranslator()->translate($this->getVocabulary()["MESSAGE_SETTINGS_NOT_CREATED"]);
             return false;
         }
     }
     if (!empty($data['setting']['galleriesImage']['name'])) {
         if (!FileUtilService::rename($data['setting']['galleriesImage'], 'images', null, "galleries-side-bg")) {
             $this->message = $this->getTranslator()->translate($this->getVocabulary()["MESSAGE_SETTINGS_NOT_CREATED"]);
             return false;
         }
     }
     if (!empty($data['setting']['servicesImage']['name'])) {
         if (!FileUtilService::rename($data['setting']['servicesImage'], 'images', null, "services-side-bg")) {
             $this->message = $this->getTranslator()->translate($this->getVocabulary()["MESSAGE_SETTINGS_NOT_CREATED"]);
             return false;
         }
     }
     if (!empty($data['setting']['contactImage']['name'])) {
         if (!FileUtilService::rename($data['setting']['contactImage'], 'images', null, "contact-side-bg")) {
             $this->message = $this->getTranslator()->translate($this->getVocabulary()["MESSAGE_SETTINGS_NOT_CREATED"]);
             return false;
         }
     }
     $this->message = $this->getTranslator()->translate($this->getVocabulary()["MESSAGE_SETTINGS_UPDATED"]);
     return true;
 }
コード例 #2
0
ファイル: PostService.php プロジェクト: JoshBour/karolina
 private function deleteImages(PostEntity $entity)
 {
     if ($thumbnail = $entity->getThumbnail()) {
         FileUtilService::deleteFile(FileUtilService::getFilePath($thumbnail, 'posts', 'public/images'));
         foreach (PostEntity::$thumbnailVariations as $key => $variation) {
             $variationImg = $entity->getThumbnail($key);
             FileUtilService::deleteFile(FileUtilService::getFilePath($variationImg, 'posts', 'public/images'));
         }
     }
 }
コード例 #3
0
ファイル: ImageService.php プロジェクト: JoshBour/karolina
 private function deleteImages(ImageEntity $entity)
 {
     if ($image = $entity->getImage()) {
         FileUtilService::deleteFile(FileUtilService::getFilePath($image, 'gallery', 'public/images'));
         foreach (ImageEntity::$thumbnailVariations as $key => $variation) {
             $variationImg = $entity->getImage($key);
             FileUtilService::deleteFile(FileUtilService::getFilePath($variationImg, 'gallery', 'public/images'));
         }
     }
 }