/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $rootNode = new DocumentNode(); $rootNode->setName('ROOT')->setUniqRef('ROOT'); $manager->persist($rootNode); $manager->flush(); }
/** * execute * * @param InputInterface $input * @param OutputInterface $output * * @SuppressWarnings("unused") * * @return mixed */ protected function execute(InputInterface $input, OutputInterface $output) { $sourceDir = $input->getArgument('source'); $manager = $this->getContainer()->get('doctrine')->getManager(); // Trying to retrieve existing destination node. $dest = $manager->getRepository('ErichardDmsBundle:DocumentNode')->findOneBySlug($input->getOption('name')); if (!isset($dest)) { // Prepare a newly created destination node $dest = new DocumentNode(); $dest->setName($input->getOption('name')); } // Launch the importer $importer = new FilesystemImporter($this->getContainer()->get('doctrine')->getManager(), array('storage_path' => $this->getContainer()->getParameter('dms.storage.path'), 'copy' => $input->getOption('copy'))); $importer->import($sourceDir, $dest, $input->getOption('exclude')); }
/** * new Node * * @param \Erichard\DmsBundle\Entity\DocumentNode $node * @param string $name * @param \Erichard\DmsBundle\Entity\DocumentNode $parentNode * * @return \Erichard\DmsBundle\Entity\DocumentNode */ public function updateNode($node, $name, $parentNode) { $node->setName($name)->setParent($parentNode)->setDepth($parentNode->getDepth() + 1); $this->registry->getManager()->flush(); return $node; }