Neos\ContentRepository\Domain\Repository\NodeDataRepository::removeAllInPath PHP Method

removeAllInPath() public method

Remove all nodes below a given path. Does not care about workspaces and dimensions.
public removeAllInPath ( string $path ) : void
$path string Starting point path underneath all nodes are to be removed.
return void
    public function removeAllInPath($path)
    {
        $path = strtolower($path);
        $query = $this->entityManager->createQuery('DELETE FROM Neos\\ContentRepository\\Domain\\Model\\NodeData n WHERE n.path LIKE :path');
        $query->setParameter('path', $path . '/%');
        $query->execute();
    }

Usage Example

コード例 #1
0
 /**
  * Remove given site all nodes for that site and all domains associated.
  *
  * @param Site $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);
 }