public function initialize(OutputInterface $output, $purge = false) { $nodeTypeManager = $this->sessionManager->getSession()->getWorkspace()->getNodeTypeManager(); foreach ([new CustomUrlNodeType(), new CustomUrlRouteNodeType()] as $nodeType) { $nodeTypeManager->registerNodeType($nodeType, true); } /** @var Webspace $webspace */ foreach ($this->webspaceManager->getWebspaceCollection() as $webspace) { $itemsPath = $this->pathBuilder->build(['%base%', $webspace->getKey(), '%custom_urls%', '%custom_urls_items%']); $routesPath = $this->pathBuilder->build(['%base%', $webspace->getKey(), '%custom_urls%', '%custom_urls_routes%']); $output->writeln(sprintf(' <info>%s</info>:', $webspace->getName())); if (true === $this->nodeManager->has($itemsPath)) { $output->writeln(sprintf(' [ ] <info>items path:</info>: %s ', $itemsPath)); } else { $output->writeln(sprintf(' [+] <info>items path:</info>: %s ', $itemsPath)); $this->nodeManager->createPath($itemsPath); } if (true === $this->nodeManager->has($routesPath)) { $output->writeln(sprintf(' [ ] <info>items path:</info>: %s ', $routesPath)); } else { $output->writeln(sprintf(' [+] <info>items path:</info>: %s ', $routesPath)); $this->nodeManager->createPath($routesPath); } $this->nodeManager->save(); } }
/** * Load the given fixture classes. * * @param array $fixtures * @param mixed $purge * @param mixed $initialize * @param OutputInterface $output */ public function execute(array $fixtures, $purge = true, $initialize = true, OutputInterface $output = null) { $output = $output ?: new NullOutput(); if (true === $purge) { $output->writeln('<comment>Purging workspace</comment>'); $this->nodeManager->purgeWorkspace(); $this->nodeManager->save(); } if (true === $initialize) { $output->writeln('<comment>Initializing repository</comment>'); $this->initializer->initialize($output); } $output->writeln('<comment>Loading fixtures</comment>'); foreach ($fixtures as $fixture) { $output->writeln(sprintf(' - %s<info>loading "</info>%s<info>"</info>', $fixture instanceof OrderedFixtureInterface ? '[' . $fixture->getOrder() . ']' : '', get_class($fixture))); $fixture->load($this->documentManager); $this->documentManager->clear(); } }
/** * @param FlushEvent $event */ public function handleFlush(FlushEvent $event) { $this->nodeManager->save(); }