예제 #1
0
파일: Folder.php 프로젝트: savvagee/thelia
 public function delete(FolderDeleteEvent $event)
 {
     if (null !== ($folder = FolderQuery::create()->findPk($event->getFolderId()))) {
         $folder->setDispatcher($event->getDispatcher())->delete();
         $event->setFolder($folder);
     }
 }
예제 #2
0
 public function delete(FolderDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     if (null !== ($folder = FolderQuery::create()->findPk($event->getFolderId()))) {
         $con = Propel::getWriteConnection(FolderTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             $fileList = ['images' => [], 'documentList' => []];
             // Get folder's files to delete after folder deletion
             $fileList['images']['list'] = FolderImageQuery::create()->findByFolderId($event->getFolderId());
             $fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
             $fileList['documentList']['list'] = FolderDocumentQuery::create()->findByFolderId($event->getFolderId());
             $fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
             // Delete folder
             $folder->setDispatcher($dispatcher)->delete($con);
             $event->setFolder($folder);
             // Dispatch delete folder's files event
             foreach ($fileList as $fileTypeList) {
                 foreach ($fileTypeList['list'] as $fileToDelete) {
                     $fileDeleteEvent = new FileDeleteEvent($fileToDelete);
                     $dispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
                 }
             }
             $con->commit();
         } catch (\Exception $e) {
             $con->rollback();
             throw $e;
         }
     }
 }
예제 #3
0
 /**
  * test folder removal
  * @covers Thelia\Action\Folder::delete
  */
 public function testDeleteFolder()
 {
     $folder = $this->getRandomFolder();
     $event = new FolderDeleteEvent($folder->getId());
     $event->setDispatcher($this->dispatcher);
     $folderAction = new Folder();
     $folderAction->delete($event);
     $deletedFolder = $event->getFolder();
     $this->assertInstanceOf('Thelia\\Model\\Folder', $deletedFolder);
     $this->assertTrue($deletedFolder->isDeleted());
 }
예제 #4
0
 /**
  * Put in this method post object delete processing if required.
  *
  * @param  \Thelia\Core\Event\Folder\FolderDeleteEvent $deleteEvent the delete event
  * @return Response                                    a response, or null to continue normal processing
  */
 protected function performAdditionalDeleteAction($deleteEvent)
 {
     return $this->generateRedirectFromRoute('admin.folders.default', ['parent' => $deleteEvent->getFolder()->getParent()]);
 }