コード例 #1
0
ファイル: Edit.php プロジェクト: acp3/module-files
 /**
  * @param array $formData
  * @param array $dl
  * @param int $fileId
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, array $dl, $fileId)
 {
     return $this->actionHelper->handleEditPostAction(function () use($formData, $dl, $fileId) {
         $file = null;
         if (isset($formData['external'])) {
             $file = $formData['file_external'];
         } elseif ($this->request->getFiles()->has('file_internal')) {
             $file = $this->request->getFiles()->get('file_internal');
         }
         $this->adminFormValidation->setFile($file)->setUriAlias(sprintf(Helpers::URL_KEY_PATTERN, $fileId))->validate($formData);
         $formData['cat'] = $this->fetchCategoryId($formData);
         $formData['comments'] = $this->useComments($formData);
         $formData['user_id'] = $this->user->getUserId();
         if (!empty($file)) {
             $newFileSql = $this->updateAssociatedFile($file, $formData, $dl['file']);
             $formData = array_merge($formData, $newFileSql);
         }
         return $this->filesModel->save($formData, $fileId);
     });
 }
コード例 #2
0
ファイル: Create.php プロジェクト: acp3/module-files
 /**
  * @param array $formData
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handleCreatePostAction(function () use($formData) {
         if (isset($formData['external'])) {
             $file = $formData['file_external'];
         } else {
             $file = $this->request->getFiles()->get('file_internal');
         }
         $this->adminFormValidation->setFile($file)->validate($formData);
         if (is_array($file) === true) {
             $upload = new Core\Helpers\Upload($this->appPath, Files\Installer\Schema::MODULE_NAME);
             $result = $upload->moveFile($file->getPathname(), $file->getClientOriginalName());
             $formData['file'] = $result['name'];
             $formData['filesize'] = $result['size'];
         } else {
             $formData['file'] = $file;
             $formData['filesize'] = (double) $formData['filesize'] . ' ' . $formData['unit'];
         }
         $formData['cat'] = $this->fetchCategoryId($formData);
         $formData['comments'] = $this->useComments($formData);
         $formData['user_id'] = $this->user->getUserId();
         return $this->filesModel->save($formData);
     });
 }
コード例 #3
0
ファイル: Delete.php プロジェクト: acp3/module-files
 /**
  * @param string $action
  *
  * @return mixed
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($action = '')
 {
     return $this->actionHelper->handleDeleteAction($action, function (array $items) {
         return $this->filesModel->delete($items);
     });
 }