Exemple #1
0
 /**
  * Transform domain to vhost.
  *
  * @param Domain    $domain
  * @param Subdomain $subdomain
  *
  * @return Vhost[]
  */
 public static function transformDomain(Domain $domain, Subdomain $subdomain = null)
 {
     /** @var Vhost[] $return */
     $return = array();
     $ips = $domain->getIpaddress();
     if (($max = count($ips)) < 1) {
         $max = 1;
     }
     for ($i = 0; $i < $max; $i++) {
         $vhost = new Vhost();
         $ip = null;
         if ($ips->containsKey($i)) {
             /** @var IpAddress $ip */
             $ip = $ips[$i];
         }
         $vhost->setDomain($domain)->setSubdomain($subdomain);
         if ($ip !== null) {
             $vhost->setIpaddress($ip);
         }
         /*
          * Only add if:
          * - Domain has no IP's (so no SSL is required).
          * - IP has no SSL support.
          * - Domain has a Certificate AND IP supports SSL.
          */
         if ($ip === null || $vhost->getSSLEnabled() || !$ip->getHasSsl()) {
             $return[] = $vhost;
         }
     }
     return $return;
 }
Exemple #2
0
 /**
  * Dataprovider for testGetVhostAddress.
  *
  * @return array
  */
 public function providerTestGetVhostAddress()
 {
     $ip4 = new IpAddress();
     $vhost4 = new Vhost();
     $ip6 = new IpAddress();
     $vhost6 = new Vhost();
     $ip4->setIp('127.0.0.1')->setPort(80);
     $vhost4->setIpaddress($ip4);
     $ip6->setIp('2001:db8::1428:57ab')->setPort(80);
     $vhost6->setIpaddress($ip6);
     return array(array($vhost4, '127.0.0.1:80'), array($vhost6, '[2001:db8::1428:57ab]:80'));
 }