/**
  * action update
  *
  * @param \GK\Stdapp\Domain\Model\Resource $resource
  * @return void
  */
 public function updateAction(\GK\Stdapp\Domain\Model\Resource $resource)
 {
     $customer = $this->portalUser->getCustomer()->_loadRealInstance();
     $data = $_FILES['tx_' . strtolower($this->request->getControllerExtensionName()) . '_' . strtolower($this->request->getPluginName())];
     if (($url = trim($resource->getUrl())) && !preg_match('/^https?:/', $url)) {
         $resource->setUrl('http://' . $url);
     }
     if ($resource->getUid() > 0) {
         $this->resourceRepository->update($resource);
         $this->flashMessageContainer->add('Your Resource was updated.');
         if ($data['error']['file'] == UPLOAD_ERR_NO_FILE) {
             $this->redirect('edit');
         }
     } else {
         $customer->addResource($resource);
         $this->customerRepository->update($customer);
         $this->flashMessageContainer->add('Your Resource was added.');
     }
     if (is_array($data) && count($data) > 0) {
         //Enforce persistence
         $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll();
         if (($err = $this->handleUpload("file", $this->settings['uploadPath'] . $customer->getIdentifier() . '/', $resource->getType()->getName() . '_' . $resource->getUid(), $filepath)) == 0) {
             $resource->setPath($filepath);
             $this->resourceRepository->update($resource);
             $this->flashMessageContainer->add('Image saved');
         } else {
             $customer->removeResource($resource);
             $this->resourceRepository->remove($resource);
             if ($err == 2) {
                 $this->flashMessageContainer->add('File too big.', "", \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
             } else {
                 $this->flashMessageContainer->add("ERROR(" . $err . ") when saving file!", "", \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
             }
         }
     }
     $this->redirect('edit');
 }
Пример #2
0
 /**
  * action delete
  *
  * @param \GK\Stdapp\Domain\Model\Resource $resource
  * @return void
  */
 public function deleteAction(\GK\Stdapp\Domain\Model\Resource $resource)
 {
     $this->resourceRepository->remove($resource);
     $this->flashMessageContainer->add('Your Resource was removed.');
     $this->redirect('list');
 }
Пример #3
0
 /**
  * action delete
  *
  * @param \GK\Stdapp\Domain\Model\Resource $banner
  * @return void
  */
 public function deleteBannerAction(\GK\Stdapp\Domain\Model\Resource $banner)
 {
     $this->resourceRepository->remove($banner);
     $this->flashMessageContainer->add('Your Resource was deleted.');
     $this->redirect('editBanner');
 }