/**
  * @test
  */
 public function setSiteSetsTheSiteTheDomainIsPointingTo()
 {
     $mockSite = $this->getMockBuilder(Site::class)->disableOriginalConstructor()->getMock();
     $domain = new Domain();
     $domain->setSite($mockSite);
     $this->assertSame($mockSite, $domain->getSite());
 }
 /**
  * Creates a new content context based on the given workspace and the NodeData object and additionally takes
  * the current site and current domain into account.
  *
  * @param Workspace $workspace Workspace for the new context
  * @param array $dimensionValues The dimension values for the new context
  * @param array $contextProperties Additional pre-defined context properties
  * @return Context
  */
 protected function createContext(Workspace $workspace, array $dimensionValues, array $contextProperties = array())
 {
     if ($this->currentDomain === false) {
         $this->currentDomain = $this->domainRepository->findOneByActiveRequest();
     }
     if ($this->currentDomain !== null) {
         $contextProperties['currentSite'] = $this->currentDomain->getSite();
         $contextProperties['currentDomain'] = $this->currentDomain;
     } else {
         if ($this->currentSite === false) {
             $this->currentSite = $this->siteRepository->findFirstOnline();
         }
         $contextProperties['currentSite'] = $this->currentSite;
     }
     return parent::createContext($workspace, $dimensionValues, $contextProperties);
 }
 /**
  * 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));
 }