|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Service;
|
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
+use App\Repository\FilmRepository;
|
|
|
|
|
|
/**
|
|
|
* Faire des recherches de films
|
|
@@ -10,14 +11,16 @@ use Doctrine\ORM\EntityManagerInterface;
|
|
|
class Search
|
|
|
{
|
|
|
protected $em;
|
|
|
+ protected $repoFilm;
|
|
|
|
|
|
/**
|
|
|
* Search constructor.
|
|
|
* @param EntityManagerInterface $em
|
|
|
*/
|
|
|
- public function __construct(EntityManagerInterface $em)
|
|
|
+ public function __construct(EntityManagerInterface $em, FilmRepository $repoFilm)
|
|
|
{
|
|
|
$this->em = $em;
|
|
|
+ $this->repoFilm = $repoFilm;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -52,8 +55,7 @@ class Search
|
|
|
*/
|
|
|
protected function searchByRealisateur($query)
|
|
|
{
|
|
|
- $q = $this->em->getRepository('App:Film');
|
|
|
- return $q->findFilmWithRealLike($query);
|
|
|
+ return $this->repoFilm->findFilmWithRealLike($query);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -62,8 +64,7 @@ class Search
|
|
|
*/
|
|
|
protected function searchByGenre($query)
|
|
|
{
|
|
|
- $q = $this->em->getRepository('App:Film');
|
|
|
- return $q->findFilmWithGenreLike($query);
|
|
|
+ return $this->repoFilm->findFilmWithGenreLike($query);
|
|
|
}
|
|
|
|
|
|
|