Neos\Neos\Command\SiteCommandController::exportCommand PHP Method

exportCommand() public method

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.
public exportCommand ( string $siteNode = null, boolean $tidy = true, string $filename = null, string $packageKey = null, string $nodeTypeFilter = null ) : void
$siteNode string the node name of the site to be exported; if none given will export all sites
$tidy boolean Whether to export formatted XML. This is defaults to true
$filename string relative path and filename to the XML file to create. Any resource will be stored in a sub folder "Resources".
$packageKey string Package to store the XML file in. Any resource will be stored in a sub folder "Resources".
$nodeTypeFilter string 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));
        }
    }