/**
  * @param AssetCollection $assetCollection
  * @return void
  */
 public function deleteAssetCollectionAction(AssetCollection $assetCollection)
 {
     foreach ($this->siteRepository->findByAssetCollection($assetCollection) as $site) {
         $site->setAssetCollection(null);
         $this->siteRepository->update($site);
     }
     parent::deleteAssetCollectionAction($assetCollection);
 }
 /**
  * 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);
 }
 /**
  * Deactivate a site
  *
  * This command deactivates the specified site.
  *
  * @param string $siteNode The node name of the site to deactivate
  * @return void
  */
 public function deactivateCommand($siteNode)
 {
     $site = $this->siteRepository->findOneByNodeName($siteNode);
     if (!$site instanceof Site) {
         $this->outputLine('<error>Site not found.</error>');
         $this->quit(1);
     }
     $site->setState(Site::STATE_OFFLINE);
     $this->siteRepository->update($site);
     $this->outputLine('Site deactivated.');
 }
 /**
  * Updates or creates a site with the given $siteNodeName
  *
  * @param string $siteNodeName
  * @return Site
  */
 protected function getSiteByNodeName($siteNodeName)
 {
     $site = $this->siteRepository->findOneByNodeName($siteNodeName);
     if ($site === null) {
         $site = new Site($siteNodeName);
         $this->siteRepository->add($site);
     } else {
         $this->siteRepository->update($site);
     }
     return $site;
 }
 /**
  * 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));
 }