Exemplo n.º 1
0
 public function updateAction()
 {
     $person = $this->contactService->findPerson($this->params('id'));
     if (!$person) {
         return $this->notFoundAction();
     }
     $this->contactForm->bind($person);
     if ($this->getRequest()->isPost()) {
         $this->contactForm->setData($this->getRequest()->getPost());
         if ($this->contactForm->isValid()) {
             $person = $this->contactService->persistContact($this->contactForm->getData());
             return $this->redirect()->toRoute('contacts/view', ['type' => ContactEntry::TYPE_PERSON, 'id' => $person->getId()->toString()]);
         }
     }
     return new ViewModel(['person' => $person, 'contactForm' => $this->contactForm]);
 }
Exemplo n.º 2
0
 public function updateAction()
 {
     $company = $this->contactService->findCompany($this->params('id'));
     if (!$company) {
         return $this->notFoundAction();
     }
     $this->contactForm->bind($company);
     if ($this->getRequest()->isPost()) {
         $this->contactForm->setData($this->getRequest()->getPost());
         if ($this->contactForm->isValid()) {
             $company = $this->contactService->persistContact($this->contactForm->getData());
             return $this->redirect()->toRoute('contacts/view', ['type' => ContactEntry::TYPE_COMPANY, 'id' => $company->getId()->toString()]);
         }
     }
     return new ViewModel(['company' => $company, 'contactForm' => $this->contactForm]);
 }