/** * {@inheritDoc} */ public function getOffset() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOffset', array()); return parent::getOffset(); }
public function testimonialsAction(Request $request) { $order_by = ''; $em = $this->get('doctrine.orm.entity_manager'); $repository = $em->getRepository('Acme\\InfoBundle\\Entity\\Testimonials'); $languagesCount = $repository->getIdCount(); $paginator = new Testimonials($languagesCount); $strPaginator = $paginator->RenderPaginator(); $testimonials = $this->get('doctrine')->getRepository('AcmeInfoBundle:Testimonials')->findAll(); return $this->render('AcmeInfoBundle:Default:testimonials.html.twig', array('testimonials' => $testimonials, 'paginator' => $strPaginator)); }
public function testieditAction(Request $request) { $id = $request->get('id'); $em = $this->getDoctrine()->getManager(); $testimonials = $em->getRepository('AcmeInfoBundle:Testimonials')->find($id); $testimonial = new \Acme\InfoBundle\Entity\Testimonials(); $testimonial->setName($testimonials->getName()); $testimonial->setPost($testimonials->getPost()); $testimonial->setDescription($testimonials->getDescription()); $form = $this->createFormBuilder($testimonials)->add('name', 'text')->add('post', 'text')->add('description', 'textarea')->getForm(); $form->handleRequest($request); $validator = $this->get('validator'); $errors = $validator->validate($form); if (count($errors) > 0) { //echo "invalid"; } else { if ($request->isMethod('post') == 'edit') { $a = $request->request->get('form'); $info = $em->getRepository('AcmeInfoBundle:Testimonials')->find($id); $info->setName($a['name']); $info->setPost($a['post']); $info->setDescription($a['description']); $em->persist($info); $em->flush(); return $this->redirect($this->generateUrl('acme_info_testimonials')); } } return $this->render('AcmeInfoBundle:Default:testiedit.html.twig', array('form' => $form->createView(), 'id' => $id)); }
public function testieditAction(Request $request) { $id = $request->get('id'); $em = $this->getDoctrine()->getManager(); $testimonials = $em->getRepository('AcmeInfoBundle:Testimonials')->find($id); $oldimg = $testimonials->getImage(); $testimonial = new \Acme\InfoBundle\Entity\Testimonials(); $testimonial->setName($testimonials->getName()); $testimonial->setPost($testimonials->getPost()); $testimonial->setDescription($testimonials->getDescription()); $form = $this->createFormBuilder($testimonial)->add('name', 'text')->add('post', 'text')->add('description', 'textarea')->add('image', 'file', array('error_bubbling' => TRUE, 'required' => false))->getForm(); $form->handleRequest($request); $validator = $this->get('validator'); $errors = $validator->validate($form); if (count($errors) > 1) { //echo "invalid"; } else { if ($request->isMethod('post') == 'edit') { if ($_FILES['form']['name']['image']) { $testi = $em->getRepository('AcmeInfoBundle:Testimonials')->find($id); unlink($_SERVER['DOCUMENT_ROOT'] . '/uploads/testimonials/' . $testi->getId() . '/' . $oldimg); $newimg = $form['image']->getData()->getClientOriginalName(); $testi->setImage($newimg); $em->persist($testi); $em->flush(); $img = $form['image']->getData()->getClientOriginalName(); $dir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/testimonials/' . $testi->getId() . '/'; $form->get('image')->getData()->move($dir, $img); return $this->redirect($this->generateUrl('acme_info_testimonials')); } else { $a = $request->request->get('form'); $info = $em->getRepository('AcmeInfoBundle:Testimonials')->find($id); $info->setName($a['name']); $info->setPost($a['post']); $info->setDescription($a['description']); $em->persist($info); $em->flush(); $this->get('session')->getFlashBag()->set('success', 'Your Record Update Successfully'); return $this->redirect($this->generateUrl('acme_info_testimonials')); } } } return $this->render('AcmeInfoBundle:Default:testiedit.html.twig', array('form' => $form->createView(), 'id' => $id, 'image' => $oldimg)); }