Neos.Neos/Classes/Controller/Module/Administration/SitesController.php
public function createSiteNodeAction($packageKey, $siteName, $nodeType)
    {
        $nodeName = $this->nodeService->generateUniqueNodeName(SiteService::SITES_ROOT_PATH, $siteName);

        if ($this->siteRepository->findOneByNodeName($nodeName)) {
            $this->addFlashMessage('Error: A site with siteNodeName "%s" already exists', 'Site creation error', Message::SEVERITY_ERROR, [$nodeName], 1412372375);
            $this->redirect('createSiteNode');
        }

        $siteNodeType = $this->nodeTypeManager->getNodeType($nodeType);

        if ($siteNodeType === null || $siteNodeType->getName() === 'Neos.Neos:FallbackNode') {
            $this->addFlashMessage('Error: The given node type "%s" was not found', 'Site creation error', Message::SEVERITY_ERROR, [$nodeType], 1412372375);
            $this->redirect('createSiteNode');
        }

        if ($siteNodeType->isOfType('Neos.Neos:Document') === false) {
            $this->addFlashMessage('Error: The given node type "%s" is not based on the superType "%s"', 'Site creation error', Message::SEVERITY_ERROR, [$nodeType, 'Neos.Neos:Document'], 1412372375);
            $this->redirect('createSiteNode');
        }

        $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', $siteName);
        $site = new Site($nodeName);
        $site->setSiteResourcesPackageKey($packageKey);
        $site->setState(Site::STATE_ONLINE);
        $site->setName($siteName);
        $this->siteRepository->add($site);

        $this->addFlashMessage('Successfully created site "%s" with siteNode "%s", type "%s" and packageKey "%s"', '', null, [$siteName, $nodeName, $nodeType, $packageKey], 1412372266);
        $this->unsetLastVisitedNodeAndRedirect('index');
    }
public function createSiteNodeAction($packageKey, $siteName, $nodeType)
    {
        $nodeName = $this->nodeService->generateUniqueNodeName(SiteService::SITES_ROOT_PATH, $siteName);

        if ($this->siteRepository->findOneByNodeName($nodeName)) {
            $this->addFlashMessage('Error: A site with siteNodeName "%s" already exists', 'Site creation error', Message::SEVERITY_ERROR, [$nodeName], 1412372375);
            $this->redirect('createSiteNode');
        }

        $siteNodeType = $this->nodeTypeManager->getNodeType($nodeType);

        if ($siteNodeType === null || $siteNodeType->getName() === 'Neos.Neos:FallbackNode') {
            $this->addFlashMessage('Error: The given node type "%s" was not found', 'Site creation error', Message::SEVERITY_ERROR, [$nodeType], 1412372375);
            $this->redirect('createSiteNode');
        }

        if ($siteNodeType->isOfType('Neos.Neos:Document') === false) {
            $this->addFlashMessage('Error: The given node type "%s" is not based on the superType "%s"', 'Site creation error', Message::SEVERITY_ERROR, [$nodeType, 'Neos.Neos:Document'], 1412372375);
            $this->redirect('createSiteNode');
        }

        $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', $siteName);
        $site = new Site($nodeName);
        $site->setSiteResourcesPackageKey($packageKey);
        $site->setState(Site::STATE_ONLINE);
        $site->setName($siteName);
        $this->siteRepository->add($site);

        $this->addFlashMessage('Successfully created site "%s" with siteNode "%s", type "%s" and packageKey "%s"', '', null, [$siteName, $nodeName, $nodeType, $packageKey], 1412372266);
        $this->unsetLastVisitedNodeAndRedirect('index');
    }
public function createSiteNodeAction ( $ packageKey , $ siteName , $ nodeType ) { $ nodeName = $ this -> nodeService -> generateUniqueNodeName ( SiteService :: SITES_ROOT_PATH , $ siteName ) ; if ( $ this -> siteRepository -> findOneByNodeName ( $ nodeName ) ) { $ this -> addFlashMessage ( 'Error: A site with siteNodeName "%s" already exists' , 'Site creation error' , Message :: SEVERITY_ERROR , [ $ nodeName ] , 1412372375 ) ; $ this -> redirect ( 'createSiteNode' ) ; } $ siteNodeType = $ this -> nodeTypeManager -> getNodeType ( $ nodeType ) ; if ( $ siteNodeType === null || $ siteNodeType -> getName ( ) === 'Neos.Neos:FallbackNode' ) { $ this -> addFlashMessage ( 'Error: The given node type "%s" was not found' , 'Site creation error' , Message :: SEVERITY_ERROR , [ $ nodeType ] , 1412372375 ) ; $ this -> redirect ( 'createSiteNode' ) ; } if ( $ siteNodeType -> isOfType ( 'Neos.Neos:Document' ) === false ) { $ this -> addFlashMessage ( 'Error: The given node type "%s" is not based on the superType "%s"' , 'Site creation error' , Message :: SEVERITY_ERROR , [ $ nodeType , 'Neos.Neos:Document' ] , 1412372375 ) ; $ this -> redirect ( 'createSiteNode' ) ; } $ 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' , $ siteName ) ; $ site = new Site ( $ nodeName ) ; $ site -> setSiteResourcesPackageKey ( $ packageKey ) ; $ site -> setState ( Site :: STATE_ONLINE ) ; $ site -> setName ( $ siteName ) ; $ this -> siteRepository -> add ( $ site ) ; $ this -> addFlashMessage ( 'Successfully created site "%s" with siteNode "%s", type "%s" and packageKey "%s"' , '' , null , [ $ siteName , $ nodeName , $ nodeType , $ packageKey ] , 1412372266 ) ; $ this -> unsetLastVisitedNodeAndRedirect ( 'index' ) ; }
Create a new empty site.

@param string $packageKey Package Name to create
@param string $siteName Site Name to create
@param string $nodeType NodeType name for the root node to create
@Flow\Validate(argumentName="$packageKey", type="\Neos\Neos\Validation\Validator\PackageKeyValidator")
@return void
Create a new empty site .