Elcodi\Store\PageBundle\Controller\BlogController::viewBlogPostAction PHP Method

viewBlogPostAction() public method

View blog post
public viewBlogPostAction ( Elcodi\Component\Page\Entity\Interfaces\PageInterface $blogPost, $slug )
$blogPost Elcodi\Component\Page\Entity\Interfaces\PageInterface
    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]);
    }