src/Controller/BlogPostController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use InvalidArgumentException;
  4. use Pimcore\Controller\FrontendController;
  5. use Pimcore\Model\DataObject;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class BlogPostController extends FrontendController
  8. {
  9.     /**
  10.      * @Route("/insights/{blogPostSlug}", name="blog_post_detail")
  11.      */
  12.     public function detailAction(string $blogPostSlug
  13.     {
  14.         $blogPost DataObject\BlogPost::getBySlug($blogPostSlug1);
  15.         if(!$blogPost){
  16.             throw new InvalidArgumentException('Blog post does not exist');
  17.         }
  18.         return $this->render('content/blogPost.html.twig', [
  19.             'blogPost' => $blogPost
  20.         ]);
  21.     }
  22. }