<?php
namespace App\Controller\Website\Tree;
use App\Entity\Tree;
use App\Entity\TreeFile;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class ShowTreeController extends AbstractController
{
#[Route('/afficher-un-arbre/{tree}', name: 'tree.show')]
public function __invoke(Tree $tree): Response
{
$treeFiles = $tree->getTreeFiles();
$treeFilesPhotos = $treeFiles->filter(function (TreeFile $treeFile) {
return $treeFile->getType() === TreeFile::PHOTO;
});
$treeFileDetailedSheet = $treeFiles->filter(function (TreeFile $treeFile) {
return $treeFile->getType() === TreeFile::DETAILED_SHEET;
})->first();
return $this->render('tree/show.html.twig', [
'tree' => $tree,
'tree_files_photos' => $treeFilesPhotos,
'tree_file_detailed_sheet' => $treeFileDetailedSheet,
]);
}
}