/** * View blog post * * @Route( * path = "/{id}/{slug}", * name = "store_blog_post_view", * methods = {"GET"} * ) * * @AnnotationEntity( * class = "elcodi.entity.page.class", * name = "blogPost", * mapping = { * "id" = "~id~", * "enabled" = true, * } * ) */ public function viewBlogPostAction(PageInterface $blogPost, $slug) { if (ElcodiPageTypes::TYPE_BLOG_POST !== $blogPost->getType()) { $this->createNotFoundException(); } /** * We must check that the product slug is right. Otherwise we must * return a Redirection 301 to the right url */ if ($slug !== $blogPost->getPath()) { return $this->redirectToRoute('store_blog_post_view', ['id' => $blogPost->getId(), 'slug' => $blogPost->getPath()]); } return $this->renderTemplate('Pages:blog-post-view.html.twig', ['blog_post' => $blogPost]); }
/** * Creates response instance * * @param PageInterface $page Page * * @return Response */ private function createResponseInstance(PageInterface $page) { $response = new Response(); $response->setLastModified($page->getUpdatedAt())->setPublic(); return $response; }
/** * Check the entity for activation capabilities * * @param PageInterface $page Page * * @throws AccessDeniedException */ private function canBeDeactivated(PageInterface $page) { if ($page->isPersistent()) { throw new AccessDeniedException($this->get('translator')->trans('admin.page.error.cant_modify_permanent')); } }