Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ProjectsController
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 index
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace App\Controller;
4
5use App\Repository\ProjectsRepository;
6use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7use Symfony\Component\HttpFoundation\Response;
8use Symfony\Component\Routing\Annotation\Route;
9
10class ProjectsController extends AbstractController
11{
12    #[Route(path: '/projects/{name}', name: 'app_projects')]
13    public function index(ProjectsRepository $projectsRepository, string $name = ''): Response
14    {
15        if ($name == '') {
16            return $this->render(view: '@default/projects/index.html.twig', parameters: [
17                'projects' => $projectsRepository->findAll(),
18            ]);
19        } else {
20            if ($project = $projectsRepository->findOneByName(value: $name)) {
21                $readMe = file_get_contents(filename: $project->getURL().'/raw/branch/master/README.md');
22
23                // $parsedReadMe = $markdownParser->transformMarkdown(text: $readMe);
24
25                return $this->render(view: '@default/projects/show.html.twig', parameters: [
26                    'project' => $project,
27                    'readme' => $readMe,
28                ]);
29            } else {
30                throw $this->createNotFoundException();
31            }
32        }
33    }
34}