/** * Indexes a page. * * @param \Sfynx\CmfBundle\Entity\Page * @return void * @access public * * @author Etienne de Longeaux <*****@*****.**> * @since 2012-06-11 */ public function indexPage(\Sfynx\CmfBundle\Entity\Page $page) { // Open the index self::open($this->_indexPath); // we set the indexation of the locale translations of the page. $translationPage = $page->getTranslationByLocale($this->language); if ($translationPage instanceof \Sfynx\CmfBundle\Entity\TranslationPage) { // if the page is sluggify, we get the entity associated $pathInfo = str_replace($this->container->get('request')->getUriForPath(''), '', $this->container->get('request')->headers->get('referer')); $page_options = $this->container->get('pi_app_admin.manager.page')->getPageMetaInfo($this->language, '', '', '', $pathInfo); if (isset($page_options['entity']) && !empty($page_options['entity'])) { $entity = $page_options['entity']; $indexValues['Title'] = $page_options['title']; if (is_object($entity) && method_exists($entity, "getPublishedAt") && $entity->getPublishedAt() instanceof \DateTime) { $indexValues['ModDate'] = $entity->getPublishedAt()->getTimestamp(); } elseif (is_object($entity) && method_exists($entity, "getUpdatedAt") && $entity->getUpdatedAt() instanceof \DateTime) { $indexValues['ModDate'] = $entity->getUpdatedAt()->getTimestamp(); } } else { $indexValues['ModDate'] = $translationPage->getPublishedAt()->getTimestamp(); $indexValues['Title'] = $translationPage->getMetaTitle(); } $indexValues['Key'] = "page:{$page->getId()}:{$this->language}:{$pathInfo}"; $indexValues['Route'] = $page->getRouteName(); $indexValues['Contents'] = $this->deleteTags(file_get_contents($this->container->get('request')->getUriForPath('') . $pathInfo)); $indexValues['Keywords'] = $translationPage->getMetaKeywords(); $indexValues['Subject'] = $translationPage->getMetaDescription(); self::$_index = Indexation::index(self::$_index, 'page', $indexValues, $this->language); } // Commit the index self::commit(); }
/** * Sets the response to one page. * * @param Page $page Page entity * @param Response $response Response instance * * @return void * @access private * @author Etienne de Longeaux <*****@*****.**> * @since 2012-01-31 */ private function setResponsePage(Page $page, Response $response) { $this->responses['page'][$page->getId()] = $response; }
/** * Deletes a Page entity. * * @param Request $request The request instance * @param Page $entity A page entity * * @Secure(roles="ROLE_EDITOR") * @return RedirectResponse * @access public * @author Etienne de Longeaux <*****@*****.**> */ public function deleteAction(Request $request, Page $entity) { $form = $this->createDeleteForm($entity->getId()); $request = $this->getRequest(); $form->bind($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); try { $em->remove($entity); $em->flush(); } catch (\Exception $e) { $this->container->get('request')->getSession()->getFlashBag()->clear(); $this->container->get('request')->getSession()->getFlashBag()->add('notice', 'pi.session.flash.wrong.undelete'); } } return $this->redirect($this->generateUrl('admin_pagebytrans')); }