/**
  * @param Request $request
  * @param Congregation $congregation
  * @param Publisher $publisher
  *
  * @ParamConverter(name="publisher", class="KingdomHallDataBundle:Publisher", isOptional="true", options={"id" = "publisherId"})
  *
  * @Template()
  * @return array
  */
 public function editAction(Request $request, Congregation $congregation, Publisher $publisher = null)
 {
     if (!$publisher) {
         $publisher = new Publisher();
         $publisher->setCongregation($congregation);
     }
     $id = $publisher->getId();
     $form = $this->createForm('kingdomhall_form_publisher', $publisher, array('action' => $this->generateUrl('kingdom_hall_publishers_edit', array('congregationCode' => $congregation->getCode(), 'publisherId' => $id ? $id : 0))));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $manager = $this->getDoctrine()->getEntityManager();
         if ($publisher->getUser()) {
             $publisher->getUser()->setEmail($publisher->getEmail());
             $this->get('kingdomhall.user_manager')->updateUser($publisher->getUser());
         }
         $manager->persist($publisher);
         $manager->flush();
     }
     return array('form' => $form->createView());
 }
Exemplo n.º 2
0
 /**
  * Set publisher
  *
  * @param \KingdomHall\DataBundle\Entity\Publisher $publisher
  * @return User
  */
 public function setPublisher(Publisher $publisher = null)
 {
     $this->publisher = $publisher;
     $publisher->setUser($this);
     return $this;
 }