/**
  * Template : Finds and displays a MediasDiaporama entity.
  * 
  * @Cache(maxage="86400")
  * @return \Symfony\Component\HttpFoundation\Response
  *
  * @access    public
  * @author Etienne de Longeaux <*****@*****.**> 
  */
 public function _template_showAction($id, $template = '_tmp_show.html.twig', $lang = "")
 {
     $em = $this->getDoctrine()->getManager();
     if (empty($lang)) {
         $lang = $this->container->get('request')->getLocale();
     }
     $entity = $em->getRepository("PluginsContentBundle:MediasDiaporama")->findOneByEntity($lang, $id, 'object', false);
     if (!$entity) {
         throw ControllerException::NotFoundException('MediasDiaporama');
     }
     if (method_exists($entity, "getTemplate") && $entity->getTemplate() != "") {
         $template = $entity->getTemplate();
     }
     return $this->render("PluginsContentBundle:MediasDiaporama:{$template}", array('entity' => $entity, 'locale' => $lang));
 }
 /**
  * Removes given $node from the tree and reparents its descendants
  * 
  * @Secure(roles="ROLE_USER")
  * @param int $id
  * @param string $category
  * @access    public
  * 
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function removeAction($id, $category)
 {
     $em = $this->getDoctrine()->getManager();
     $locale = $this->container->get('request')->getLocale();
     $node = $em->getRepository("PluginsContentBundle:Rub")->findNodeOr404($id, $locale);
     $NoLayout = $this->container->get('request')->query->get('NoLayout');
     //$em->getRepository("PluginsContentBundle:Rub")->removeFromTree($node);
     if (!$node) {
         throw ControllerException::NotFoundException('Rub');
     }
     try {
         if (method_exists($node, 'setArchived')) {
             $node->setArchived(true);
         }
         if (method_exists($node, 'setEnabled')) {
             $node->setEnabled(false);
         }
         if (method_exists($node, 'setArchiveAt')) {
             $node->setArchiveAt(new \DateTime());
         }
         if (method_exists($node, 'setPosition')) {
             $node->setPosition(null);
         }
         $em->persist($node);
         $em->flush();
         $this->container->get('request')->getSession()->getFlashBag()->add('notice', 'Rubrique supprimée avec succès');
     } catch (\Exception $e) {
         $this->container->get('request')->getSession()->getFlashBag()->add('notice', 'pi.session.flash.wrong.undelete');
     }
     return $this->redirect($this->generateUrl('admin_content_rub_tree', array('category' => $category, 'NoLayout' => $NoLayout)));
 }
 /**
  * Deletes a BlocGeneral entity.
  *
  * @Secure(roles="ROLE_USER")
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *     
  * @access    public
  * @author Etienne de Longeaux <*****@*****.**>     
  */
 public function deleteAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $locale = $this->container->get('request')->getLocale();
     $NoLayout = $this->container->get('request')->query->get('NoLayout');
     $category = $this->container->get('request')->query->get('category');
     $form = $this->createDeleteForm($id);
     $request = $this->getRequest();
     $form->bind($request);
     if ($form->isValid()) {
         $entity = $em->getRepository("PluginsContentBundle:BlocGeneral")->findOneByEntity($locale, $id, 'object');
         if (!$entity) {
             throw ControllerException::NotFoundException('BlocGeneral');
         }
         try {
             $em->remove($entity);
             $em->flush();
         } catch (\Exception $e) {
             $this->container->get('request')->getSession()->getFlashBag()->add('notice', 'pi.session.flash.wrong.undelete');
         }
     }
     return $this->redirect($this->generateUrl('admin_content_bloc_general', array('NoLayout' => $NoLayout, 'category' => $category)));
 }
 /**
  * Deletes a Diaporama entity.
  *
  * @Secure(roles="ROLE_USER")
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *     
  * @access    public
  * @author Etienne de Longeaux <*****@*****.**>     
  */
 public function deleteAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $locale = $this->container->get('request')->getLocale();
     $NoLayout = $this->container->get('request')->query->get('NoLayout');
     $category = $this->container->get('request')->query->get('category');
     $form = $this->createDeleteForm($id);
     $request = $this->getRequest();
     $form->bind($request);
     if ($form->isValid()) {
         $entity = $em->getRepository("PluginsContentBundle:Diaporama")->findOneByEntity($locale, $id, 'object');
         if (!$entity) {
             throw ControllerException::NotFoundException('Diaporama');
         }
         try {
             if (method_exists($entity, 'setArchived')) {
                 $entity->setArchived(true);
             }
             if (method_exists($entity, 'setEnabled')) {
                 $entity->setEnabled(false);
             }
             if (method_exists($entity, 'setArchiveAt')) {
                 $entity->setArchiveAt(new \DateTime());
             }
             if (method_exists($entity, 'setPosition')) {
                 $entity->setPosition(null);
             }
             $entity->getBlocgeneral()->setArchived(true);
             $entity->getBlocgeneral()->setEnabled(false);
             $entity->getBlocgeneral()->setArchiveAt(new \DateTime());
             $em->persist($entity);
             $em->flush();
         } catch (\Exception $e) {
             $this->container->get('request')->getSession()->getFlashBag()->add('notice', 'pi.session.flash.wrong.undelete');
         }
     }
     return $this->redirect($this->generateUrl('admin_content_bloc_general', array('NoLayout' => $NoLayout, 'category' => $category, 'type' => 'diaporama')));
 }