mirror of
https://github.com/doctrine/doctrine-website.git
synced 2026-03-23 22:32:11 +01:00
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.
52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Doctrine\Website\Controllers;
|
|
|
|
use Doctrine\Website\Model\Project;
|
|
use Doctrine\Website\Repositories\ProjectRepository;
|
|
use Doctrine\Website\StaticGenerator\Controller\Response;
|
|
|
|
final readonly class ProjectController
|
|
{
|
|
/** @param ProjectRepository<Project> $projectRepository */
|
|
public function __construct(
|
|
private ProjectRepository $projectRepository,
|
|
) {
|
|
}
|
|
|
|
public function index(): Response
|
|
{
|
|
return new Response([
|
|
'primaryProjects' => $this->projectRepository->findPrimaryProjects(),
|
|
'inactiveProjects' => $this->projectRepository->findInactiveProjects(),
|
|
'archivedProjects' => $this->projectRepository->findArchivedProjects(),
|
|
'integrationProjects' => $this->projectRepository->findIntegrationProjects(),
|
|
]);
|
|
}
|
|
|
|
public function view(string $slug): Response
|
|
{
|
|
$project = $this->projectRepository->findOneBySlug($slug);
|
|
|
|
return new Response([
|
|
'project' => $project,
|
|
'integrationProjects' => $this->projectRepository->findProjectIntegrations($project),
|
|
], '/project.html.twig');
|
|
}
|
|
|
|
public function version(string $slug, string $versionSlug): Response
|
|
{
|
|
$project = $this->projectRepository->findOneBySlug($slug);
|
|
|
|
$version = $project->getVersion($versionSlug);
|
|
|
|
return new Response([
|
|
'project' => $project,
|
|
'version' => $version,
|
|
'latestTag' => $version->getLatestTag(),
|
|
], '/project-version.html.twig');
|
|
}
|
|
}
|