/** * @param Request $request * @return Response */ protected function handle(Request $request) { $userId = Auth::getUserId(); $vars = array(); $folderContentId = intval($request->get('foldercontent')); $parentFolderId = intval($request->get('toFolder')); if ($folderContentId && $parentFolderId && $request->get('copy')) { try { $this->folderDao->copyContent($folderContentId, $parentFolderId); } catch (Exception $ex) { $vars['message'] = $ex->getMessage(); } } elseif ($folderContentId && $parentFolderId) { try { $this->folderDao->moveContent($folderContentId, $parentFolderId); } catch (Exception $ex) { $vars['message'] = $ex->getMessage(); } } $rootFolderId = $this->folderDao->getRootFolder($userId)->getId(); /* @var $uiFolderNav FolderNav */ $uiFolderNav = $this->getObject('ui.folder.nav'); $vars['folderTree'] = $uiFolderNav->showFolderTree($rootFolderId); $vars['folderStructure'] = $this->folderDao->getFolderStructure($rootFolderId); return $this->render('admin_content_move.html.twig', $this->mergeWithDefault($vars)); }
/** * @expectedException Exception */ public function testMoveContentShouldFailIfCyclesAreProduced() { $this->folderDao->ensureTopLevelFolder(); $folderA = $this->folderDao->insertFolder($folderName = 'A', '/A', FolderDao::TOP_LEVEL); $folderB = $this->folderDao->insertFolder($folderName = 'B', '/A/B', $folderA); $fc = $this->dbManager->getSingleRow('SELECT foldercontents_pk FROM foldercontents WHERE child_id=$1', array($folderA), __METHOD__ . '.needs.the.foldercontent_pk'); $this->folderDao->moveContent($fc['foldercontents_pk'], $folderB); }