Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ProjectsController | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| index | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Controller; |
| 4 | |
| 5 | use App\Repository\ProjectsRepository; |
| 6 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
| 7 | use Symfony\Component\HttpFoundation\Response; |
| 8 | use Symfony\Component\Routing\Annotation\Route; |
| 9 | |
| 10 | class 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 | } |