Files
archived-doctrine-website/lib/Controllers/BlogController.php
Christophe Coevoet 495b4ac8f4 Inline the static website generator in the website repo
Maintaining a standalone static website generator project that is not
reused outside our website adds maintenance overhead. For instance,
support for using `phpdocumentor/guides` was implemented in the website
repo rather than the standalone generator package, which was still using
the `doctrine/rst-parser` package that we want to abandon.
2025-10-09 21:46:37 +02:00

40 lines
928 B
PHP

<?php
declare(strict_types=1);
namespace Doctrine\Website\Controllers;
use Doctrine\Website\Model\BlogPost;
use Doctrine\Website\Repositories\BlogPostRepository;
use Doctrine\Website\StaticGenerator\Controller\Response;
final readonly class BlogController
{
/** @param BlogPostRepository<BlogPost> $blogPostRepository */
public function __construct(
private BlogPostRepository $blogPostRepository,
) {
}
public function index(): Response
{
return new Response([
'blogPosts' => $this->blogPostRepository->findPaginated(),
]);
}
public function archive(): Response
{
return new Response([
'blogPosts' => $this->blogPostRepository->findAll(),
]);
}
public function view(string $slug): Response
{
return new Response([
'blogPost' => $this->blogPostRepository->find($slug),
]);
}
}