<?php
namespace App\Controller;
use InvalidArgumentException;
use Pimcore\Controller\FrontendController;
use Pimcore\Model\DataObject;
use Symfony\Component\Routing\Annotation\Route;
class BlogPostController extends FrontendController
{
/**
* @Route("/insights/{blogPostSlug}", name="blog_post_detail")
*/
public function detailAction(string $blogPostSlug)
{
$blogPost = DataObject\BlogPost::getBySlug($blogPostSlug, 1);
if(!$blogPost){
throw new InvalidArgumentException('Blog post does not exist');
}
return $this->render('content/blogPost.html.twig', [
'blogPost' => $blogPost
]);
}
}