protected function execute(InputInterface $input, OutputInterface $output)
 {
     $domain = new \Hollo\BindBundle\Entity\Domain();
     $domain->setDomain($input->getArgument('domain'));
     $domain->setAddress($input->getArgument('address'));
     $domain->setDescription($input->getArgument('description'));
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $em->persist($domain);
     $em->flush();
     $event = new \Hollo\BindBundle\Event\FilterDomainEvent($domain);
     $this->getContainer()->get('event_dispatcher')->dispatch(\Hollo\BindBundle\Event\Events::onDomainAdd, $event);
     $output->writeln(sprintf('Added domain <comment>%s</comment>', $domain->getDomain()));
 }
 /**
  * @Template()
  * @Route("/ptr/new")
  */
 public function newAction()
 {
     $domain = new \Hollo\BindBundle\Entity\Domain();
     $domain->setDomain('0.168.192.in-addr.arpa');
     $domain->setType('ptr');
     $form = $this->createForm(new \Hollo\BindBundle\Form\PTR(), $domain);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bindRequest($this->getRequest());
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getEntityManager();
             $em->persist($domain);
             $em->flush();
             $event = new \Hollo\BindBundle\Event\FilterDomainEvent($domain);
             $this->get('event_dispatcher')->dispatch(\Hollo\BindBundle\Event\Events::onDomainAdd, $event);
             $this->get('session')->setFlash('notice', 'Your data has been saved.');
             return $this->redirect($this->generateUrl('hollo_bind_adminptr_index'));
         }
     }
     return array('form' => $form->createView());
 }
示例#3
0
 private function buildDomain($zone)
 {
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $domain = new \Hollo\BindBundle\Entity\Domain();
     $domain->setDomain($zone['domain']);
     $domain->setDescription('Migrated');
     if (preg_match("/arpa\$/", $zone['domain'])) {
         $domain->setType('ptr');
     } else {
         $domain->setType('domain');
     }
     $em->persist($domain);
     foreach ($zone as $type => $records) {
         if (is_array($records)) {
             foreach ($records as $r) {
                 switch ($type) {
                     case 'A':
                     case 'PTR':
                         $record = new \Hollo\BindBundle\Entity\Record();
                         $record->setName($r['name']);
                         $record->setAddress($r['destination']);
                         $record->setType($type);
                         $record->setDomain($domain);
                         $em->persist($record);
                         break;
                     case 'CNAME':
                         $name = preg_replace("/\\." . $domain->getDomain() . "\\.\$/", "", $r['name']);
                         $record = new \Hollo\BindBundle\Entity\Record();
                         $record->setName($name);
                         $record->setAddress($r['destination']);
                         $record->setType($type);
                         $record->setDomain($domain);
                         $em->persist($record);
                         break;
                     case 'MX':
                         $record = new \Hollo\BindBundle\Entity\Record();
                         $record->setPriority($r['priority']);
                         $record->setAddress($r['destination']);
                         $record->setType($type);
                         $record->setDomain($domain);
                         $em->persist($record);
                         break;
                 }
             }
         }
     }
     return $domain;
 }