Пример #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;
 }
Пример #2
0
 /**
  * Get directory options.
  *
  * @return array
  */
 public function getDirectoryOptions()
 {
     $options = parent::getDirectoryOptions();
     foreach ($options as $key => $value) {
         $pathOld = $value['path'];
         $pathNew = substr($pathOld, strlen($this->getDocumentRoot()));
         if (empty($pathNew)) {
             $pathNew = '/';
         }
         $value['path'] = $pathNew;
         $options[$key] = $value;
     }
     return $options;
 }
Пример #3
0
 /**
  * Test getDirectoryOptions().
  */
 public function testGetDirectoryOptions()
 {
     $domain = new Domain();
     $po1 = new PathOption($domain);
     $po2 = new PathOption($domain);
     $po3 = new PathOption($domain);
     $protection1 = new Protection($domain);
     $protection2 = new Protection($domain);
     $protection3 = new Protection($domain);
     $domain->setPath('/var/www/domain.de')->setWebroot('htdocs/test');
     $domain->getPathoption()->add($po1);
     $domain->getPathoption()->add($po2);
     $domain->getPathoption()->add($po3);
     $domain->getProtection()->add($protection1);
     $domain->getProtection()->add($protection2);
     $domain->getProtection()->add($protection3);
     $po1->setPath('htdocs/test/subfolder');
     $po2->setPath('htdocs');
     $po3->setPath('htdocs/test');
     $protection1->setPath('htdocs');
     $protection2->setPath('htdocs/test/subfolder2');
     $protection3->setPath('htdocs/test');
     $vhost = new Vhost();
     $vhost->setDomain($domain);
     $options = $vhost->getDirectoryOptions();
     $this->assertCount(2, $options);
     $testPo = false;
     $testProt = false;
     foreach ($options as $optset) {
         if ($optset['pathoption'] !== null) {
             $this->assertEquals($po1, $optset['pathoption']);
             $testPo = true;
         }
         if ($optset['protection'] !== null) {
             $this->assertEquals($protection2, $optset['protection']);
             $testProt = true;
         }
     }
     $this->assertTrue($testPo);
     $this->assertTrue($testProt);
 }