Beispiel #1
0
 /**
  * @param string $action
  *
  * @return array|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($action = '')
 {
     return $this->actionHelper->handleDeleteAction($action, function (array $items) {
         $result = $this->categoriesModel->delete($items);
         $this->categoriesCache->getCacheDriver()->deleteAll();
         return $result;
     });
 }
Beispiel #2
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handleCreatePostAction(function () use($formData) {
         $file = $this->request->getFiles()->get('picture');
         $this->adminFormValidation->setFile($file)->setSettings($this->config->getSettings(Categories\Installer\Schema::MODULE_NAME))->validate($formData);
         if (!empty($file)) {
             $upload = new Core\Helpers\Upload($this->appPath, Categories\Installer\Schema::MODULE_NAME);
             $result = $upload->moveFile($file->getPathname(), $file->getClientOriginalName());
             $formData['picture'] = $result['name'];
         }
         return $this->categoriesModel->save($formData);
     });
 }