Пример #1
0
 /**
  * Get resource record by type.
  */
 public function testGetAAAA()
 {
     $zc = new ZoneCollection();
     $zc->add(new SOA())->add(new A())->add(new NS())->add(new NS())->add(new AAAA())->add(new AAAA())->add(new A());
     $return = $zc->getByType('AAAA');
     $this->assertTrue(is_array($return));
     $this->assertInstanceOf('Jeboehm\\Lampcp\\ZoneGeneratorBundle\\Model\\ResourceRecord\\AAAA', $return[0]);
 }
Пример #2
0
 /**
  * Get a default zone for new entries
  *
  * @return ZoneCollection
  */
 protected function _getDefaultZone()
 {
     $nsdefault = $this->_getConfigService()->getParameter('dns.default.ns');
     $zone = new ZoneCollection();
     $ns = new NS();
     $soa = new SOA();
     $soa->setPrimary($nsdefault)->setMail($this->getUser()->getEmail() . '.');
     $ns->setRdata($nsdefault);
     $zone->add($soa)->add($ns);
     return $zone;
 }
Пример #3
0
 /**
  * Create zone
  *
  * @return string
  */
 protected function _createZone()
 {
     $content = array();
     $records = array_merge(array($this->_collection->getSoa()), $this->_collection->getValues());
     foreach ($records as $record) {
         /** @var $record AbstractResourceRecord */
         $template = $this->_loadTemplate($record->getType());
         $variables = $this->_searchVariables($template);
         foreach ($variables as $var) {
             $replace = call_user_func(array($record, sprintf('get%s', ucfirst($var))));
             $template = str_replace('%' . $var . '%', $replace, $template);
         }
         $content[] = $template;
     }
     return join('', $content);
 }
Пример #4
0
 /**
  * Transform ZoneCollection to DnsResourceModel Array
  *
  * @param ZoneCollection $value
  *
  * @return array
  */
 public function transform($value)
 {
     if ($value instanceof ZoneCollection) {
         $arr = array();
         $position = 0;
         foreach ($value->getValues() as $rr) {
             /** @var $rr AbstractResourceRecord */
             $dnsResourceModel = new DnsResourceModel();
             $dnsResourceModel->setName($rr->getName())->setTtl($rr->getTtl())->setType($rr->getType())->setRdata($rr->getRdata())->setPosition($position);
             $arr[] = $dnsResourceModel;
             $position++;
         }
         return $arr;
     } else {
         return $value;
     }
 }