/** * Export sites content (e.g. site:export --package-key "Neos.Demo") * * This command exports all or one specific site with all its content into an XML format. * * If the package key option is given, the site(s) will be exported to the given package in the default * location Resources/Private/Content/Sites.xml. * * If the filename option is given, any resources will be exported to files in a folder named "Resources" * alongside the XML file. * * If neither the filename nor the package key option are given, the XML will be printed to standard output and * assets will be embedded into the XML in base64 encoded form. * * @param string $siteNode the node name of the site to be exported; if none given will export all sites * @param boolean $tidy Whether to export formatted XML. This is defaults to true * @param string $filename relative path and filename to the XML file to create. Any resource will be stored in a sub folder "Resources". * @param string $packageKey Package to store the XML file in. Any resource will be stored in a sub folder "Resources". * @param string $nodeTypeFilter Filter the node type of the nodes, allows complex expressions (e.g. "Neos.Neos:Page", "!Neos.Neos:Page,Neos.Neos:Text") * @return void */ public function exportCommand($siteNode = null, $tidy = true, $filename = null, $packageKey = null, $nodeTypeFilter = null) { if ($siteNode === null) { $sites = $this->siteRepository->findAll()->toArray(); } else { $sites = $this->siteRepository->findByNodeName($siteNode)->toArray(); } if (count($sites) === 0) { $this->outputLine('<error>No site for exporting found</error>'); $this->quit(1); } if ($packageKey !== null) { $this->siteExportService->exportToPackage($sites, $tidy, $packageKey, $nodeTypeFilter); if ($siteNode !== null) { $this->outputLine('The site "%s" has been exported to package "%s".', array($siteNode, $packageKey)); } else { $this->outputLine('All sites have been exported to package "%s".', array($packageKey)); } } elseif ($filename !== null) { $this->siteExportService->exportToFile($sites, $tidy, $filename, $nodeTypeFilter); if ($siteNode !== null) { $this->outputLine('The site "%s" has been exported to "%s".', array($siteNode, $filename)); } else { $this->outputLine('All sites have been exported to "%s".', array($filename)); } } else { $this->output($this->siteExportService->export($sites, $tidy, $nodeTypeFilter)); } }
/** * @test */ public function exportingAPreviouslyImportedSiteLeadsToTheSameStructure() { $expectedResult = file_get_contents(__DIR__ . '/Fixtures/Sites.xml'); $actualResult = $this->siteExportService->export(array($this->importedSite), true); $this->assertEquals($expectedResult, $actualResult); }