|
@@ -13,7 +13,10 @@ class TmdbApiService
|
|
|
protected int $nbResults = 0;
|
|
|
protected array $films = [];
|
|
|
|
|
|
- public function __construct(protected HttpClientInterface $tmdbClient, protected UniciteCollections $uc)
|
|
|
+ public function __construct(
|
|
|
+ protected HttpClientInterface $tmdbClient,
|
|
|
+ protected UniciteCollections $uc
|
|
|
+ )
|
|
|
{
|
|
|
|
|
|
}
|
|
@@ -24,14 +27,12 @@ class TmdbApiService
|
|
|
$response = $this->tmdbClient->request(
|
|
|
'GET',
|
|
|
'search/movie',[
|
|
|
- 'query' => [
|
|
|
- 'language' => 'fr',
|
|
|
+ 'query' => [
|
|
|
'query' => $titre
|
|
|
]
|
|
|
]
|
|
|
);
|
|
|
|
|
|
- //dump($response->getContent());
|
|
|
$this->content = $response->getContent();
|
|
|
$this->jsonDecode();
|
|
|
} catch (\Exception $e) {
|
|
@@ -48,8 +49,7 @@ class TmdbApiService
|
|
|
'GET',
|
|
|
'movie/'. $id ,[
|
|
|
'query' => [
|
|
|
- 'language' => 'fr',
|
|
|
- 'append_to_response' => 'credits'
|
|
|
+ 'append_to_response' => 'credits,videos',
|
|
|
]
|
|
|
]
|
|
|
);
|
|
@@ -75,7 +75,6 @@ class TmdbApiService
|
|
|
{
|
|
|
$json = json_decode($this->content);
|
|
|
|
|
|
- //dump($json);
|
|
|
$this->nbResults = $json->total_results;
|
|
|
$entrees = $json->results;
|
|
|
|
|
@@ -91,43 +90,43 @@ class TmdbApiService
|
|
|
{
|
|
|
$filmTmdb = json_decode($this->getDetailMovie($filmTmdbId));
|
|
|
|
|
|
- dump($filmTmdb);
|
|
|
-
|
|
|
- $film = new Film();
|
|
|
+ dump($filmTmdb);
|
|
|
+
|
|
|
+ $film = new Film();
|
|
|
+ $film
|
|
|
+ ->setTitre($filmTmdb->title)
|
|
|
+ ->setInformation($filmTmdb->overview);
|
|
|
+
|
|
|
+ if (preg_match ("/^\d{4}-\d{2}-\d{2}$/", $filmTmdb->release_date))
|
|
|
+ {
|
|
|
+ $dateSortie = $filmTmdb->release_date;
|
|
|
+ dump($dateSortie);
|
|
|
+ $annee = substr($dateSortie, 0, 4) . '-01-01';
|
|
|
+ dump($annee);
|
|
|
$film
|
|
|
- ->setTitre($filmTmdb->title)
|
|
|
- ->setInformation($filmTmdb->overview);
|
|
|
-
|
|
|
- if (preg_match ("/^\d{4}-\d{2}-\d{2}$/", $filmTmdb->release_date))
|
|
|
- {
|
|
|
- $dateSortie = $filmTmdb->release_date;
|
|
|
- dump($dateSortie);
|
|
|
- $annee = substr($dateSortie, 0, 4) . '-01-01';
|
|
|
- dump($annee);
|
|
|
- $film
|
|
|
- ->setDateSortie(new \DateTimeImmutable($dateSortie))
|
|
|
- ->setAnnee(new \DateTimeImmutable($annee))
|
|
|
- ;
|
|
|
-
|
|
|
- } elseif (preg_match("/^\d{4}/", $filmTmdb->release_date)) {
|
|
|
- $annee = substr($filmTmdb->release_date, 0, 4) . '-01-01';
|
|
|
- $film
|
|
|
- ->setAnnee(new \DateTimeImmutable($annee));
|
|
|
- ;
|
|
|
- }
|
|
|
+ ->setDateSortie(new \DateTimeImmutable($dateSortie))
|
|
|
+ ->setAnnee(new \DateTimeImmutable($annee))
|
|
|
+ ;
|
|
|
|
|
|
+ } elseif (preg_match("/^\d{4}/", $filmTmdb->release_date)) {
|
|
|
+ $annee = substr($filmTmdb->release_date, 0, 4) . '-01-01';
|
|
|
+ $film
|
|
|
+ ->setAnnee(new \DateTimeImmutable($annee));
|
|
|
;
|
|
|
- foreach ($filmTmdb->genres as $genre) {
|
|
|
- $film->addGenre((new Genre())->setName($genre->name));
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- foreach ($this->getRealisateurs($filmTmdb) as $realisateur) {
|
|
|
- $film->addRealisateur($realisateur);
|
|
|
- }
|
|
|
+ ;
|
|
|
+ foreach ($filmTmdb->genres as $genre) {
|
|
|
+ $film->addGenre((new Genre())->setName($genre->name));
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($this->getRealisateurs($filmTmdb) as $realisateur) {
|
|
|
+ $film->addRealisateur($realisateur);
|
|
|
+ }
|
|
|
|
|
|
- $film = $this->uc->assureUniciteCollections($film);
|
|
|
- dump($film);
|
|
|
- return $film;
|
|
|
+ $film = $this->uc->assureUniciteCollections($film);
|
|
|
+ dump($film);
|
|
|
+ return $film;
|
|
|
}
|
|
|
|
|
|
public function getRealisateurs($detailMovie): array
|