public function createCommand($name, $packageKey, $nodeType = 'Neos.Neos.NodeTypes:Page', $nodeName = null, $inactive = false)
{
if ($nodeName === null) {
$nodeName = $this->nodeService->generateUniqueNodeName(SiteService::SITES_ROOT_PATH, $name);
}
if ($this->siteRepository->findOneByNodeName($nodeName)) {
$this->outputLine('<error>A site with siteNodeName "%s" already exists</error>', [$nodeName]);
$this->quit(1);
}
if ($this->packageManager->isPackageAvailable($packageKey) === false) {
$this->outputLine('<error>Could not find package "%s"</error>', [$packageKey]);
$this->quit(1);
}
$siteNodeType = $this->nodeTypeManager->getNodeType($nodeType);
if ($siteNodeType === null || $siteNodeType->getName() === 'Neos.Neos:FallbackNode') {
$this->outputLine('<error>The given node type "%s" was not found</error>', [$nodeType]);
$this->quit(1);
}
if ($siteNodeType->isOfType('Neos.Neos:Document') === false) {
$this->outputLine('<error>The given node type "%s" is not based on the superType "%s"</error>', [$nodeType, 'Neos.Neos:Document']);
$this->quit(1);
}
$rootNode = $this->nodeContextFactory->create()->getRootNode();
// We fetch the workspace to be sure it's known to the persistence manager and persist all
// so the workspace and site node are persisted before we import any nodes to it.
$rootNode->getContext()->getWorkspace();
$this->persistenceManager->persistAll();
$sitesNode = $rootNode->getNode(SiteService::SITES_ROOT_PATH);
if ($sitesNode === null) {
$sitesNode = $rootNode->createNode(NodePaths::getNodeNameFromPath(SiteService::SITES_ROOT_PATH));
}
$siteNode = $sitesNode->createNode($nodeName, $siteNodeType);
$siteNode->setProperty('title', $name);
$site = new Site($nodeName);
$site->setSiteResourcesPackageKey($packageKey);
$site->setState($inactive ? Site::STATE_OFFLINE : Site::STATE_ONLINE);
$site->setName($name);
$this->siteRepository->add($site);
$this->outputLine('Successfully created site "%s" with siteNode "%s", type "%s", packageKey "%s" and state "%s"', [$name, $nodeName, $nodeType, $packageKey, $inactive ? 'offline' : 'online']);
}