예제 #1
0
 public function handleImageRemove($imageName)
 {
     if (!$this->authorizator->isAllowed($this->user, 'image', 'remove')) {
         $this->flashMessage('authorization.noPermission', FlashMessage::WARNING);
         $this->redirect('this');
     }
     try {
         $this->imageFacade->removeImage($imageName);
         $this->flashMessage('images.overview.actions.remove.messages.success', FlashMessage::SUCCESS);
     } catch (FileRemovalException $fr) {
         $this->flashMessage('images.overview.actions.remove.messages.removalError', FlashMessage::ERROR, ['name' => $imageName]);
     } catch (DBALException $e) {
         $this->flashMessage('images.overview.actions.remove.messages.removalError', FlashMessage::ERROR, ['name' => $imageName]);
     }
     $this->redirect('this');
 }
예제 #2
0
 public function processImageUpload(Form $form, $values)
 {
     if (!$this->authorizator->isAllowed($this->user, 'image', 'upload')) {
         $this->flashMessage('authorization.noPermission', FlashMessage::WARNING);
         return;
     }
     /** @var FileUpload $image */
     $image = $values->image;
     try {
         if ($image->isOk()) {
             $this->imageFacade->saveImage($image);
             $this->flashMessage('images.uploadForm.messages.success', FlashMessage::SUCCESS);
             $this->redirect('this');
         }
     } catch (NotImageUploadedException $iu) {
         $form->addError($this->translator->translate('images.uploadForm.messages.wrongFileType'));
     } catch (FileSizeException $fs) {
         $form->addError($this->translator->translate('images.uploadForm.messages.wrongFileSize', ['size' => $this->imageSize]));
     } catch (InvalidStateException $is) {
         $form->addError($this->translator->translate('images.uploadForm.messages.savingError'));
     } catch (DBALException $e) {
         $form->addError($this->translator->translate('images.uploadForm.messages.savingError'));
     }
 }