Example #1
0
 /**
  * {@inheritdoc}
  */
 public function setRequestDomain($httpHost, $reset = FALSE)
 {
     // @TODO: Investigate caching methods.
     $this->setHttpHost($httpHost);
     if ($domain = $this->domainLoader->loadByHostname($httpHost)) {
         // If the load worked, set an exact match flag for the hook.
         $domain->setMatchType(DOMAIN_MATCH_EXACT);
     } elseif ($domain = $this->domainLoader->loadDefaultDomain()) {
         $domain->setMatchType(DOMAIN_MATCH_NONE);
     } else {
         $values = array('hostname' => $httpHost);
         $domain = \Drupal::entityManager()->getStorage('domain')->create($values);
         $domain->setMatchType(DOMAIN_MATCH_NONE);
     }
     // Now check with modules (like Domain Alias) that register alternate
     // lookup systems with the main module.
     $this->moduleHandler->alter('domain_request', $domain);
     // We must have registered a valid id, else the request made no match.
     $id = $domain->id();
     if (!empty($id)) {
         $this->setActiveDomain($domain);
     }
 }