src/Controller/DefaultController.php line 175
<?php
namespace App\Controller;
use App\Entity\Actualite;
use App\Entity\Chercheur;
use App\Entity\DomaineScientifique;
use App\Entity\Etablissement;
use App\Entity\Membre;
use App\Entity\Projet;
use App\Entity\Publication;
use App\Entity\StructureRecherche;
use App\Repository\StructureRechercheRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use DateTime;
class DefaultController extends AbstractController
{
#[Route('/', name: 'app_home')]
public function index(ManagerRegistry $doctrine): Response
{
$dateAuj = new DateTime();
$projets = $doctrine->getRepository(Projet::class)->findProjetActive($dateAuj);
// Récupération des actualités triées
$actualites = $doctrine->getRepository(Actualite::class)->findActualiteAsc($dateAuj);
// dump($actualites,$projets);die;
$nbrProjet = $doctrine->getRepository(Projet::class)->countProjet();
$nbrChercheurs = count($doctrine->getRepository(Chercheur::class)->findAll());
$nbrPublications = $doctrine->getRepository(Publication::class)->countPublication();
$nbrStructureRecherche = $doctrine->getRepository(StructureRecherche::class)->countStructureRecherche();
return $this->render('default/index.html.twig', [
'controller_name' => 'DefaultController',
'projets'=>$projets,
'actualites'=>$actualites,
'nbrProjet'=>$nbrProjet[0] ? $nbrProjet[0]['nbr'] : 0,
'nbrChercheurs'=>$nbrChercheurs,
'nbrPublications'=>$nbrPublications[0] ? $nbrPublications[0]['nbr'] : 0,
'nbrStructureRecherche'=>$nbrStructureRecherche[0] ? $nbrStructureRecherche[0]['nbr'] : 0,
]);
}
#[Route('/list/laboratoire', name: 'app_laboratoire')]
public function listLabo(ManagerRegistry $doctrine ,Request $request,StructureRechercheRepository $structureLaboRepository ): Response
{
//$structuresLabo = $doctrine->getRepository(StructureRecherche::class)->findBy(['type' => 2 ,'etat'=>1]);
$structuresLabo = $doctrine->getRepository(StructureRecherche::class)->findBy(['etat'=>1]);
$nbrChercheursInscrit = $doctrine->getRepository(Chercheur::class)->countChercheursInscrit();
$nbrStructureRechercheUnite = $doctrine->getRepository(StructureRecherche::class)->countStructureRechercheUnite();
$nbrStructureRechercheLabo = $doctrine->getRepository(StructureRecherche::class)->countStructureRechercheLabo();
$nbrProjet = $doctrine->getRepository(Projet::class)->countProjet();
// Récupérez les établissements et les domaines pour les filtres
$etablissements = $doctrine->getRepository(Etablissement::class)->findAll();
$domaines = $doctrine->getRepository(DomaineScientifique::class)->findAll();
return $this->render('fronts/list_laboratoires.html.twig', [
'structureLabo' => $structuresLabo,
'etablissements' => $etablissements,
'domaines' => $domaines,
'nbrChercheursInscrit'=>$nbrChercheursInscrit[0]['nbr'],
'nbrStructureRechercheUnite'=>$nbrStructureRechercheUnite[0]['nbr'],
'nbrStructureRechercheLabo'=>$nbrStructureRechercheLabo[0]['nbr'],
'nbrProjet'=>$nbrProjet[0]['nbr'],
]);
}
#[Route('/{id}/laboratoire', name: 'app_laboratoire_details')]
public function detailsLabo(ManagerRegistry $doctrine ,$id ): Response
{
$labo = $doctrine->getRepository(StructureRecherche::class)->find($id);
$projetsOfStructure =$doctrine->getRepository(Projet::class)->findBy(['structure'=>$labo]);
$nbrChercheurs = $doctrine->getRepository(Chercheur::class)->countChercheursStruc($id);
$nbrProjet = $doctrine->getRepository(Projet::class)->countProjetStruc($id);
$nbrPublications = $doctrine->getRepository(Publication::class)->countPublicationStruc($id);
return $this->render('fronts/labo_details.html.twig', [
'controller_name' => 'DefaultController',
'labo' =>$labo,
'projets'=>$projetsOfStructure,
'nbrPublications'=> $nbrPublications[0]['nbr'],
'nbrChercheurs'=>$nbrChercheurs[0]['nbr'],
'nbrProjet'=>$nbrProjet[0]['nbr'],
]);
}
#[Route('/list/projets/{idStructure?}', name: 'app_projets')]
public function listProjet(ManagerRegistry $doctrine, $idStructure = null): Response
{
if ($idStructure) {
$structure = $doctrine->getRepository(StructureRecherche::class)->find($idStructure);
$projets = $doctrine->getRepository(Projet::class)->findBy(['etat' => 2, 'structure' => $structure]);
} else {
$structure = null;
$projets = $doctrine->getRepository(Projet::class)->findBy(['etat' => 2]);
}
$structures = $doctrine->getRepository(StructureRecherche::class)->findBy(['etat'=>1]);
return $this->render('fronts/list_projets.html.twig', [
'controller_name' => 'DefaultController',
'projets' => $projets,
'structure'=>$structure ,
'structures'=>$structures
]);
}
#[Route('/{id}/projet', name: 'app_projet_details')]
public function detailsProjet(ManagerRegistry $doctrine ,$id ): Response
{
$projet = $doctrine->getRepository(Projet::class)->find($id);
// $chercheursProjet = $doctrine->getRepository(Membre::class)->membreProjets($id);
$chercheursProjet = $doctrine->getRepository(Membre::class)->findBy(['projet'=>$projet]);
//dump($chercheursProjet);die;
return $this->render('fronts/projet_details.html.twig', [
'controller_name' => 'DefaultController',
'projet' =>$projet,
'chercheursProjet'=>$chercheursProjet
]);
}
#[Route('/list/chercheurs/{idStructure?}', name: 'app_chercheurs')]
public function listChercheurs(ManagerRegistry $doctrine,$idStructure = null ): Response
{
$nomStructure=null;
if ($idStructure) {
$structure = $doctrine->getRepository(StructureRecherche::class)->find($idStructure);
$nomStructure=$structure->getNomLong();
$chercheurs = $doctrine->getRepository(Chercheur::class)->findBy(['structure' => $structure],['prenom'=>'ASC']);
} else {
$structure = null;
$chercheurs = $doctrine->getRepository(Chercheur::class)->findBy([],['prenom'=>'ASC']);
}
$structures = $doctrine->getRepository(StructureRecherche::class)->findBy(['etat'=>1]);
$etablissements = $doctrine->getRepository(Etablissement::class)->findAll();
return $this->render('fronts/list_chercheurs.html.twig', [
// 'controller_name' => 'DefaultController',
'chercheurs' =>$chercheurs,
'structures'=>$structures,
'nomStructure'=>$nomStructure,
'etablissements'=>$etablissements
]);
}
#[Route('/{idChercheur}/chercheur/details', name: 'app_chercheurs_details')]
public function detailsChercheurs(ManagerRegistry $doctrine ,$idChercheur): Response
{
$chercheur = $doctrine->getRepository(Chercheur::class)->find($idChercheur);
return $this->render('fronts/details_chercheur.html.twig', [
// 'controller_name' => 'DefaultController',
'chercheur' =>$chercheur
]);
}
#[Route('/list/publications', name: 'app_publications')]
public function listPublications(ManagerRegistry $doctrine ): Response
{
$publications = $doctrine->getRepository(Publication::class)->findAll();
$structures = $doctrine->getRepository(StructureRecherche::class)->findBy(['etat'=>1]);
$annees = array_unique(array_map(function($pub) {
return $pub->getAnnee();
}, $publications));
sort($annees);
return $this->render('fronts/list_publications.html.twig', [
'controller_name' => 'DefaultController',
'publications' =>$publications,
'structures'=>$structures,
'annees'=>$annees
]);
}
}