コード例 #1
0
 public function doBind(array $taintedData)
 {
     $valid = parent::doBind($taintedData);
     if (!is_numeric($taintedData['contact'])) {
         $em = $this->getOption('entity_manager');
         $company = new Contact();
         $company->setName($taintedData['contact']);
         $company->setType(2);
         $this->getData()->setContact($company);
         $em->persist($company);
     }
     return $valid;
 }
コード例 #2
0
 public function newCompanyAction()
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $contact = new Contact();
     $contact->setType(2);
     $form = new ContactForm('contact', $contact, $this->container->get('validator'), array('entity_manager' => $em));
     if ('POST' === $this->get('request')->getMethod()) {
         $form->bind($this->get('request')->get('contact'));
         if ($form->isValid()) {
             $em = $this->container->get('doctrine.orm.entity_manager');
             $em->persist($contact);
             $em->flush();
             //$this->container->getSessionService()->setFlash('project_create', array('project' => $project));
             return $this->redirect($this->generateUrl('contacts'));
         }
     }
     return $this->render('ChiaBundle:Contacts:new_company.twig', array('form' => $form));
 }
コード例 #3
0
ファイル: Project.php プロジェクト: jackbravo/symfony-sandbox
 /**
  * Set contact
  *
  * @param Contact $contact
  */
 public function setContact($contact)
 {
     if (isset($contact) && $this->getId() && $this->contact && $this->contact->getId() != $contact->getId()) {
         $this->getLastNote()->addChange("Contact changed from '{$this->contact}' to '{$contact}'");
     }
     $this->contact = $contact;
 }