/**
  * 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);
 }
 /**
  * Delete a domain record by hostname
  *
  * @param string $hostname The hostname to remove
  * @return void
  */
 public function deleteCommand($hostname)
 {
     $domain = $this->domainRepository->findOneByHostname($hostname);
     if (!$domain instanceof Domain) {
         $this->outputLine('<error>Domain not found.</error>');
         $this->quit(1);
     }
     $this->domainRepository->remove($domain);
     $this->outputLine('Domain entry deleted.');
 }
 /**
  * Deletes a domain attached to a site
  *
  * @param Domain $domain A domain to delete
  * @Flow\IgnoreValidation("$domain")
  * @return void
  */
 public function deleteDomainAction(Domain $domain)
 {
     $site = $domain->getSite();
     if ($site->getPrimaryDomain() === $domain) {
         $site->setPrimaryDomain(null);
         $this->siteRepository->update($site);
     }
     $this->domainRepository->remove($domain);
     $this->addFlashMessage('The domain "%s" has been deleted.', 'Domain deleted', Message::SEVERITY_OK, array(htmlspecialchars($domain)), 1412373310);
     $this->unsetLastVisitedNodeAndRedirect('edit', null, null, array('site' => $site));
 }