Example #1
0
 /**
  * @Route("/opening/{slug}")
  * @Template("CraftLocationBundle:Edit:edit.html.twig")
  */
 public function openingAction(Location $location, Request $request)
 {
     if ($location->getOpeningTimes() === null) {
         $location->setOpeningTimes(new OpeningTimes());
     }
     $form = $this->createForm(new OpeningTimesType(), $location->getOpeningTimes());
     $form->handleRequest($request);
     if ($form->get('remove')->isClicked()) {
         $location->setOpeningTimes(null);
         $this->get('location_service')->updateLocation($location, $this->getUser(), $request);
         return $this->redirectToView($location);
     }
     if ($form->isValid()) {
         $this->get('location_service')->updateLocation($location, $this->getUser(), $request);
         return $this->redirectToView($location);
     }
     return ['form' => $form->createView(), 'headline' => 'Opening Times'];
 }