Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 /**
  * Get service.
  *
  * @return VhostBuilderService
  */
 public function serviceProvider()
 {
     $service = $this->getVhostBuilderService();
     $certificate = new Certificate();
     $user = new User();
     $defaultIpSsl = new IpAddress();
     $defaultIp = new IpAddress();
     $certificate->setName('normal')->setCertificateFile('asd')->setCertificateKeyFile('dodooodood');
     $user->setName('jeff')->setGroupname('jeff')->setUid(1000)->setGid(1000);
     $defaultIp->setAlias('default, no ssl')->setHasSsl(false)->setIp('127.0.0.1')->setPort(80);
     $defaultIpSsl->setAlias('default, ssl')->setHasSsl(true)->setIp('127.0.0.1')->setPort(443);
     $domain1 = new Domain();
     $domain2 = new Domain();
     $domain3 = new Domain();
     $domain1->setDomain('lampcp1.de')->setPath('/var/www/lampcp1.de')->setParsePhp(true)->setUser($user)->setWebroot('htdocs')->setCertificate($certificate);
     $domain2->setDomain('lampcp2.de')->setPath('/var/www/lampcp2.de')->setParsePhp(true)->setUser($user)->setWebroot('htdocs');
     $domain3->setDomain('lampcp3.de')->setPath('/var/www/lampcp3.de')->setParsePhp(false)->setUser($user)->setWebroot('htdocs')->setCertificate($certificate);
     $domain1->getIpaddress()->add($defaultIp);
     $domain2->getIpaddress()->add($defaultIpSsl);
     $domain2->getIpaddress()->add($defaultIp);
     $domain3->getIpaddress()->add($defaultIpSsl);
     $subdomain1 = new Subdomain($domain1);
     $subdomain2 = new Subdomain($domain2);
     $subdomain1->setSubdomain('nopaste');
     $subdomain2->setSubdomain('wiki');
     $domain1->getSubdomain()->add($subdomain1);
     $domain2->getSubdomain()->add($subdomain2);
     $service->setDomains(array($domain1, $domain2, $domain3));
     return array(array($service));
 }
Ejemplo n.º 3
0
 /**
  * Get parent domain and set some properties
  * from alias domain.
  *
  * @param Domain $domain
  *
  * @return Domain
  */
 public static function transformAliasDomain(Domain $domain)
 {
     if ($domain->getParent() !== null) {
         $parent = clone $domain->getParent();
         $parent->setDomain($domain->getDomain())->setIpaddress($domain->getIpaddress())->setCertificate($domain->getCertificate());
         return $parent;
     }
     return $domain;
 }