コード例 #1
0
 /**
  * Add noVisits
  *
  * @param TerritoryNoVisit $noVisits
  * @return Territory
  */
 public function addNoVisit(TerritoryNoVisit $noVisits)
 {
     $this->noVisits[] = $noVisits;
     $noVisits->setTerritory($this);
     return $this;
 }
コード例 #2
0
 /**
  * @param Request          $request
  * @param Congregation     $congregation
  * @param Territory        $territory
  * @param TerritoryNoVisit $noVisit
  *
  * @ParamConverter(name="territory", class="KingdomHallDataBundle:Territory", options={"id" = "territoryId"})
  * @ParamConverter(name="noVisit", isOptional=true, class="KingdomHallDataBundle:TerritoryNoVisit", options={"id" = "noVisitId"})
  *
  * @return array
  *
  * @Template()
  */
 public function editNoVisitAction(Request $request, Congregation $congregation, Territory $territory, TerritoryNoVisit $noVisit = null)
 {
     if (!$noVisit) {
         $noVisit = new TerritoryNoVisit();
         $noVisit->setTerritory($territory);
     }
     $id = $noVisit->getId();
     $form = $this->createForm('kingdomhall_form_territory_no_visit', $noVisit, array('action' => $this->generateUrl('kingdom_hall_territories_novisit_edit', array('congregationCode' => $congregation->getCode(), 'territoryId' => $territory->getId(), 'noVisitId' => $id ? $id : 0))));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $territory->addNoVisit($noVisit);
         $manager = $this->getDoctrine()->getManager();
         $manager->persist($territory);
         $manager->flush();
     }
     return array('form' => $form->createView());
 }