/** * {@inheritDoc} */ public function setContent($content) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setContent', array($content)); return parent::setContent($content); }
public function addstaticpageAction(Request $request) { /****** Admin session checking**********/ $response = $this->checkAdmin($request->getSession()); if ($response) { return $response; } $staticpage = new Staticpage(); $staticpage_content = new StaticpageContent(); $em = $this->getDoctrine()->getManager(); if ($request->getMethod() == "POST") { $url = strtolower(str_replace(' ', '-', preg_replace('/[^a-zA-Z0-9_ -]/s', ' ', $request->request->get('pagename')))); $check = $em->createQuery("SELECT p FROM MytripAdminBundle:Staticpage p WHERE p.url !='' AND p.url='" . $url . "'")->getArrayResult(); if (empty($check)) { $staticpage->setUrl($url); $staticpage->setMainMenu('No'); $staticpage->setMenuId($request->request->get('mainmenu')); $staticpage->setPagename($request->request->get('pagename')); $staticpage->setSeo('Yes'); $staticpage->setContent('Yes'); $staticpage->setStatus('Active'); $em->persist($staticpage); $em->flush(); $em = $this->getDoctrine()->getManager(); $lastid = $staticpage->getStaticpageId(); $staticpage_content->setStaticpage($this->getDoctrine()->getRepository('MytripAdminBundle:Staticpage')->find($lastid)); $staticpage_content->setName($request->request->get('pagename')); $staticpage_content->setPageTitle($request->request->get('pagetitle')); $staticpage_content->setMetaDescription($request->request->get('metadescription')); $staticpage_content->setMetaKeyword($request->request->get('metakeyword')); $staticpage_content->setContent($request->request->get('pagecontent')); $staticpage_content->setLan('en'); $em->persist($staticpage_content); $em->flush(); $this->get('session')->getFlashBag()->add('error', '<div class="success msg">Content page successfully added</div>'); return $this->redirect($this->generateUrl('mytrip_admin_staticpage')); } else { $this->get('session')->getFlashBag()->add('error', '<div class="error msg">Content page already exists</div>'); } } return $this->render('MytripAdminBundle:Default:addstaticpage.html.php'); }