Neos\Neos\Domain\Service\SiteService::pruneSite PHP Method

pruneSite() public method

Remove given site all nodes for that site and all domains associated.
public pruneSite ( Site $site ) : void
$site Neos\Neos\Domain\Model\Site
return void
    public function pruneSite(Site $site)
    {
        $siteNodePath = NodePaths::addNodePathSegment(static::SITES_ROOT_PATH, $site->getNodeName());
        $this->nodeDataRepository->removeAllInPath($siteNodePath);
        $siteNodes = $this->nodeDataRepository->findByPath($siteNodePath);
        foreach ($siteNodes as $siteNode) {
            $this->nodeDataRepository->remove($siteNode);
        }
        $site->setPrimaryDomain(null);
        $this->siteRepository->update($site);
        $domainsForSite = $this->domainRepository->findBySite($site);
        foreach ($domainsForSite as $domain) {
            $this->domainRepository->remove($domain);
        }
        $this->persistenceManager->persistAll();
        $this->siteRepository->remove($site);
        $this->emitSitePruned($site);
    }

Usage Example

 /**
  * Remove all content and related data - for now. In the future we need some more sophisticated cleanup.
  *
  * @param string $siteNode Name of a site root node to clear only content of this site.
  * @param string $siteNodeName This option is deprecated, use --site-node instead
  * @return void
  */
 public function pruneCommand($siteNode = null, $siteNodeName = null)
 {
     if ($siteNode !== null) {
         $siteNodeName = $siteNode;
     }
     if ($siteNodeName !== null) {
         $possibleSite = $this->siteRepository->findOneByNodeName($siteNodeName);
         if ($possibleSite === null) {
             $this->outputLine('The given site site node did not match an existing site.');
             $this->quit(1);
         }
         $this->siteService->pruneSite($possibleSite);
         $this->outputLine('Site with root "' . $siteNodeName . '" has been removed.');
     } else {
         $this->siteService->pruneAll();
         $this->outputLine('All sites and content have been removed.');
     }
 }
All Usage Examples Of Neos\Neos\Domain\Service\SiteService::pruneSite