/**
* Fetches the site with the given name and exports it into XML in the given package.
*
* @param array<Site> $sites
* @param boolean $tidy Whether to export formatted XML
* @param string $packageKey Package key where the export output should be saved to
* @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
* @throws NeosException
*/
public function exportToPackage(array $sites, $tidy = false, $packageKey, $nodeTypeFilter = null)
{
if (!$this->packageManager->isPackageActive($packageKey)) {
throw new NeosException(sprintf('Error: Package "%s" is not active.', $packageKey), 1404375719);
}
$contentPathAndFilename = sprintf('resource://%s/Private/Content/Sites.xml', $packageKey);
$this->resourcesPath = Files::concatenatePaths(array(dirname($contentPathAndFilename), 'Resources'));
Files::createDirectoryRecursively($this->resourcesPath);
$this->xmlWriter = new \XMLWriter();
$this->xmlWriter->openUri($contentPathAndFilename);
$this->xmlWriter->setIndent($tidy);
$this->exportSites($sites, $nodeTypeFilter);
$this->xmlWriter->flush();
}