M1.1 : nettoyer le code
This commit is contained in:
parent
30010bce1f
commit
f9c0ed3a63
7 changed files with 64 additions and 60 deletions
|
|
@ -26,8 +26,9 @@ class FormationsController extends AbstractController {
|
||||||
* @var CategorieRepository
|
* @var CategorieRepository
|
||||||
*/
|
*/
|
||||||
private $categorieRepository;
|
private $categorieRepository;
|
||||||
|
private $formationPage = "/pages/formations.html.twig";
|
||||||
|
|
||||||
function __construct(FormationRepository $formationRepository, CategorieRepository $categorieRepository) {
|
public function __construct(FormationRepository $formationRepository, CategorieRepository $categorieRepository) {
|
||||||
$this->formationRepository = $formationRepository;
|
$this->formationRepository = $formationRepository;
|
||||||
$this->categorieRepository= $categorieRepository;
|
$this->categorieRepository= $categorieRepository;
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +37,7 @@ class FormationsController extends AbstractController {
|
||||||
public function index(): Response{
|
public function index(): Response{
|
||||||
$formations = $this->formationRepository->findAll();
|
$formations = $this->formationRepository->findAll();
|
||||||
$categories = $this->categorieRepository->findAll();
|
$categories = $this->categorieRepository->findAll();
|
||||||
return $this->render("pages/formations.html.twig", [
|
return $this->render($this->formationPage, [
|
||||||
'formations' => $formations,
|
'formations' => $formations,
|
||||||
'categories' => $categories
|
'categories' => $categories
|
||||||
]);
|
]);
|
||||||
|
|
@ -46,7 +47,7 @@ class FormationsController extends AbstractController {
|
||||||
public function sort($champ, $ordre, $table=""): Response{
|
public function sort($champ, $ordre, $table=""): Response{
|
||||||
$formations = $this->formationRepository->findAllOrderBy($champ, $ordre, $table);
|
$formations = $this->formationRepository->findAllOrderBy($champ, $ordre, $table);
|
||||||
$categories = $this->categorieRepository->findAll();
|
$categories = $this->categorieRepository->findAll();
|
||||||
return $this->render("pages/formations.html.twig", [
|
return $this->render($this->formationPage, [
|
||||||
'formations' => $formations,
|
'formations' => $formations,
|
||||||
'categories' => $categories
|
'categories' => $categories
|
||||||
]);
|
]);
|
||||||
|
|
@ -57,7 +58,7 @@ class FormationsController extends AbstractController {
|
||||||
$valeur = $request->get("recherche");
|
$valeur = $request->get("recherche");
|
||||||
$formations = $this->formationRepository->findByContainValue($champ, $valeur, $table);
|
$formations = $this->formationRepository->findByContainValue($champ, $valeur, $table);
|
||||||
$categories = $this->categorieRepository->findAll();
|
$categories = $this->categorieRepository->findAll();
|
||||||
return $this->render("pages/formations.html.twig", [
|
return $this->render($this->formationPage, [
|
||||||
'formations' => $formations,
|
'formations' => $formations,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'valeur' => $valeur,
|
'valeur' => $valeur,
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,9 @@ class PlaylistsController extends AbstractController {
|
||||||
* @var CategorieRepository
|
* @var CategorieRepository
|
||||||
*/
|
*/
|
||||||
private $categorieRepository;
|
private $categorieRepository;
|
||||||
|
private $playlistPage = "/pages/playlists.html.twig";
|
||||||
|
|
||||||
function __construct(PlaylistRepository $playlistRepository,
|
public function __construct(PlaylistRepository $playlistRepository,
|
||||||
CategorieRepository $categorieRepository,
|
CategorieRepository $categorieRepository,
|
||||||
FormationRepository $formationRespository) {
|
FormationRepository $formationRespository) {
|
||||||
$this->playlistRepository = $playlistRepository;
|
$this->playlistRepository = $playlistRepository;
|
||||||
|
|
@ -62,9 +63,11 @@ class PlaylistsController extends AbstractController {
|
||||||
case "name":
|
case "name":
|
||||||
$playlists = $this->playlistRepository->findAllOrderByName($ordre);
|
$playlists = $this->playlistRepository->findAllOrderByName($ordre);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$categories = $this->categorieRepository->findAll();
|
$categories = $this->categorieRepository->findAll();
|
||||||
return $this->render("pages/playlists.html.twig", [
|
return $this->render($this->playlistPage, [
|
||||||
'playlists' => $playlists,
|
'playlists' => $playlists,
|
||||||
'categories' => $categories
|
'categories' => $categories
|
||||||
]);
|
]);
|
||||||
|
|
@ -75,7 +78,7 @@ class PlaylistsController extends AbstractController {
|
||||||
$valeur = $request->get("recherche");
|
$valeur = $request->get("recherche");
|
||||||
$playlists = $this->playlistRepository->findByContainValue($champ, $valeur, $table);
|
$playlists = $this->playlistRepository->findByContainValue($champ, $valeur, $table);
|
||||||
$categories = $this->categorieRepository->findAll();
|
$categories = $this->categorieRepository->findAll();
|
||||||
return $this->render("pages/playlists.html.twig", [
|
return $this->render($this->playlistPage, [
|
||||||
'playlists' => $playlists,
|
'playlists' => $playlists,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'valeur' => $valeur,
|
'valeur' => $valeur,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class Formation
|
||||||
/**
|
/**
|
||||||
* Début de chemin vers les images
|
* Début de chemin vers les images
|
||||||
*/
|
*/
|
||||||
private const cheminImage = "https://i.ytimg.com/vi/";
|
private const CHEMINIMAGE = "https://i.ytimg.com/vi/";
|
||||||
|
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
|
|
@ -110,12 +110,12 @@ class Formation
|
||||||
|
|
||||||
public function getMiniature(): ?string
|
public function getMiniature(): ?string
|
||||||
{
|
{
|
||||||
return self::cheminImage.$this->videoId."/default.jpg";
|
return self::CHEMINIMAGE.$this->videoId."/default.jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPicture(): ?string
|
public function getPicture(): ?string
|
||||||
{
|
{
|
||||||
return self::cheminImage.$this->videoId."/hqdefault.jpg";
|
return self::CHEMINIMAGE.$this->videoId."/hqdefault.jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPlaylist(): ?playlist
|
public function getPlaylist(): ?playlist
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,11 @@ class FormationRepository extends ServiceEntityRepository
|
||||||
/**
|
/**
|
||||||
* Retourne toutes les formations triées sur un champ
|
* Retourne toutes les formations triées sur un champ
|
||||||
* @param type $champ
|
* @param type $champ
|
||||||
* @param type $ordre
|
* @param string $ordre
|
||||||
* @param type $table si $champ dans une autre table
|
* @param type $table si $champ dans une autre table
|
||||||
* @return Formation[]
|
* @return Formation[]
|
||||||
*/
|
*/
|
||||||
public function findAllOrderBy($champ, $ordre, $table=""): array{
|
public function findAllOrderBy($champ, string $ordre, $table=""): array{
|
||||||
if($table==""){
|
if($table==""){
|
||||||
return $this->createQueryBuilder('f')
|
return $this->createQueryBuilder('f')
|
||||||
->orderBy('f.'.$champ, $ordre)
|
->orderBy('f.'.$champ, $ordre)
|
||||||
|
|
@ -82,10 +82,10 @@ class FormationRepository extends ServiceEntityRepository
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne les n formations les plus récentes
|
* Retourne les n formations les plus récentes
|
||||||
* @param type $nb
|
* @param int $nb
|
||||||
* @return Formation[]
|
* @return Formation[]
|
||||||
*/
|
*/
|
||||||
public function findAllLasted($nb) : array {
|
public function findAllLasted(int $nb) : array {
|
||||||
return $this->createQueryBuilder('f')
|
return $this->createQueryBuilder('f')
|
||||||
->orderBy('f.publishedAt', 'DESC')
|
->orderBy('f.publishedAt', 'DESC')
|
||||||
->setMaxResults($nb)
|
->setMaxResults($nb)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class PlaylistRepository extends ServiceEntityRepository
|
||||||
/**
|
/**
|
||||||
* Retourne toutes les playlists triées sur le nom de la playlist
|
* Retourne toutes les playlists triées sur le nom de la playlist
|
||||||
* @param type $champ
|
* @param type $champ
|
||||||
* @param type $ordre
|
* @param string $ordre
|
||||||
* @return Playlist[]
|
* @return Playlist[]
|
||||||
*/
|
*/
|
||||||
public function findAllOrderByName($ordre): array{
|
public function findAllOrderByName($ordre): array{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue