コード例 #1
0
 private function getDropHiddenDirectory(Dropzone $dropzone, Drop $drop)
 {
     $em = $this->getDoctrine()->getManager();
     $hiddenDropDirectory = $drop->getHiddenDirectory();
     if ($hiddenDropDirectory === null) {
         $hiddenDropDirectory = new Directory();
         // slugify user name
         $slugify = new Slugify();
         $user = $drop->getUser();
         $str = $user->getFirstName() . "-" . $user->getLastName();
         $str = $slugify->slugify($str, ' ');
         $name = $this->get('translator')->trans('Copy n°%number%', array('%number%' => $drop->getNumber()), 'innova_collecticiel');
         $name .= " - " . $str;
         $hiddenDropDirectory->setName($name);
         $parent = $this->getDropZoneHiddenDirectory($dropzone);
         $role = $this->getDoctrine()->getRepository('ClarolineCoreBundle:Role')->findManagerRole($dropzone->getResourceNode()->getWorkspace());
         $resourceManager = $this->get('claroline.manager.resource_manager');
         $resourceManager->create($hiddenDropDirectory, $resourceManager->getResourceTypeByName('directory'), $parent->getCreator(), $parent->getWorkspace(), $parent, null, array('ROLE_WS_MANAGER' => array('open' => true, 'export' => true, 'create' => array(), 'role' => $role)));
         $drop->setHiddenDirectory($hiddenDropDirectory->getResourceNode());
         $em->persist($drop);
         $em->flush();
     }
     return $drop->getHiddenDirectory();
 }