/** * move node * * @param \Erichard\DmsBundle\Entity\DocumentNode $node * @param \Erichard\DmsBundle\Entity\DocumentNode $parentNode * * @return \Erichard\DmsBundle\Entity\DocumentNode */ public function moveNode($node, $parentNode) { $node->setParent($parentNode); $this->registry->getManager()->persist($node); $this->registry->getManager()->flush(); return $node; }
/** * importDir * * @param array $currentNode * @param integer $depth * @param mixed $file * @param DocumentNodeInterface $targetNode * * @return DocumentNode */ public function importDir($currentNode, $depth, $file, $targetNode) { $node = new DocumentNode(); $node->setParent($currentNode[$depth])->setName($file->getBaseName())->setDepth($targetNode->getDepth() + $depth + 1); if (isset($this->options['node_callback']) && is_callable($this->options['node_callback'])) { call_user_func_array($this->options['node_callback'], array($node)); } $this->emn->persist($node); return $node; }
/** * createAction * * @param string $node * * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function createAction($node) { $emn = $this->get('doctrine')->getManager(); $parentNode = $this->findNodeOrThrowError($node); $newNode = new DocumentNode(); $newNode->setParent($parentNode); $form = $this->createForm('dms_node', $newNode); $form->bind($this->get('request')); if (!$form->isValid()) { $response = $this->render('ErichardDmsBundle:Standard/Node:add.html.twig', array('node' => $parentNode, 'form' => $form->createView())); } else { $metadatas = $form->get('metadatas')->getData(); foreach ($metadatas as $metaName => $metaValue) { if (null !== $metaValue) { $metadata = new DocumentNodeMetadataLnk($emn->getRepository('Erichard\\DmsBundle\\Entity\\Metadata')->findOneByName($metaName)); $metadata->setValue($metaValue); $newNode->addMetadata($metadata); $emn->persist($metadata); } } $emn->persist($newNode); $emn->flush(); if ($this->get('event_dispatcher')->hasListeners(DmsEvents::NODE_CREATE)) { $event = new DmsNodeEvent($newNode); $this->get('event_dispatcher')->dispatch(DmsEvents::NODE_CREATE, $event); } $this->get('session')->getFlashBag()->add('success', 'documentNode.add.successfully_created'); $response = $this->redirect($this->generateUrl('erichard_dms_node_list', array('node' => $node))); } return $response; }