Exemplo n.º 1
0
Arquivo: Create.php Projeto: acp3/cms
 /**
  * @param array $formData
  * @param array $settings
  * @param int   $galleryId
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, array $settings, $galleryId)
 {
     return $this->actionHelper->handleCreatePostAction(function () use($formData, $settings, $galleryId) {
         /** @var UploadedFile $file */
         $file = $this->request->getFiles()->get('file');
         $this->pictureFormValidation->setFileRequired(true)->setFile($file)->validate([]);
         $upload = new Core\Helpers\Upload($this->appPath, Gallery\Installer\Schema::MODULE_NAME);
         $result = $upload->moveFile($file->getPathname(), $file->getClientOriginalName());
         $formData['file'] = $result['name'];
         $formData['gallery_id'] = $galleryId;
         $lastId = $this->pictureModel->save($formData);
         $bool2 = $this->generatePictureAlias($lastId);
         return $lastId && $bool2;
     }, 'acp/gallery/index/edit/id_' . $galleryId);
 }
Exemplo n.º 2
0
Arquivo: Edit.php Projeto: acp3/cms
 /**
  * @param array $formData
  * @param array $settings
  * @param array $picture
  * @param int   $pictureId
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, array $settings, array $picture, $pictureId)
 {
     return $this->actionHelper->handleEditPostAction(function () use($formData, $settings, $picture, $pictureId) {
         /** @var UploadedFile $file */
         $file = $this->request->getFiles()->get('file');
         $this->pictureFormValidation->setFileRequired(false)->setFile($file)->validate([]);
         if (!empty($file)) {
             $upload = new Core\Helpers\Upload($this->appPath, Gallery\Installer\Schema::MODULE_NAME);
             $result = $upload->moveFile($file->getPathname(), $file->getClientOriginalName());
             $this->galleryHelpers->removePicture($picture['file']);
             $formData['file'] = $result['name'];
         }
         $formData['gallery_id'] = $picture['gallery_id'];
         return $this->pictureModel->save($formData, $pictureId);
     }, 'acp/gallery/index/edit/id_' . $picture['gallery_id']);
 }