/** * Creates a new Photo entity. * * @Route("/", name="secured_photo_create") * @Method("POST") * @Template("adminBatimentBundle:Photo:new.html.twig") */ public function createAction(Request $request) { $entity = new Photo(); $entity->setLogger($this->get('logger')); $form = $this->createCreateForm($entity); $form->handleRequest($request); if ($this->getRequest()->isMethod('POST')) { if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $date = new \DateTime("now"); $entity->setCreatedAt($date); $entity->setUpdatedAt($date); $entity->upload(); $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('secured_photo_show', array('id' => $entity->getId()))); } } return array('entity' => $entity, 'form' => $form->createView()); }