Esempio n. 1
0
 /**
  * @Route("/media/edit-info/{id}", name="ed_blog_admin_media_edit_info")
  * @ParamConverter("media", class="ApplicationSonataMediaBundle:Media")
  */
 public function editInfoAction(Request $request, Media $media)
 {
     $user = $this->getBlogUser();
     $form = $this->createForm(new MediaInfoType(), array("description" => $media->getDescription()));
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $media->setDescription($form['description']->getData());
             $em = $this->getDoctrine()->getManager();
             $em->persist($media);
             $em->flush();
         }
         if ($request->isXmlHttpRequest()) {
             return new JsonResponse(array('success' => true));
         } else {
             $this->get('session')->getFlashBag()->add('success', 'Photo details updated successfully.');
             return $this->redirectToRoute('ed_blog_admin_media_list');
         }
     }
     return $this->render("EDBlogBundle:Media:editInfoForm.html.twig", array("id" => $media->getId(), "form" => $form->createView()));
 }
 /**
  * {@inheritDoc}
  */
 public function getDescription()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDescription', array());
     return parent::getDescription();
 }