From 079084050f86ac44c6126703da1dba6bd8dc14f6 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Wed, 5 Feb 2014 20:55:26 +0100 Subject: [PATCH] Fixing up profile_path hydration. --- examples/movies/model/all.php | 8 ++++++-- lib/Tmdb/Factory/PeopleFactory.php | 21 ++++----------------- lib/Tmdb/Model/Movie.php | 2 +- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/examples/movies/model/all.php b/examples/movies/model/all.php index d5d50513..abb8a459 100644 --- a/examples/movies/model/all.php +++ b/examples/movies/model/all.php @@ -23,7 +23,11 @@ $imageHelper = new \Tmdb\Helper\ImageHelper($config); $repository = new \Tmdb\Repository\MovieRepository($client); -$movie = $repository->load(87421); + +/** + * @var \Tmdb\Model\Movie $movie + */ +$movie = $repository->load(87421); echo $movie->getTitle() . "
"; @@ -49,7 +53,7 @@ echo "Images
"; -// All collection classes support filtering by closure functions, provided by the Guzzle collection implementation. +// All collection classes support filtering by closure functions, provided by the generic collection implementation. foreach($movie->getImages()->filter( function($key, $value){ if ($value->getIso6391() == 'en' && $value instanceof \Tmdb\Model\Image\PosterImage) { return true; } diff --git a/lib/Tmdb/Factory/PeopleFactory.php b/lib/Tmdb/Factory/PeopleFactory.php index a94d7e82..3343fbab 100644 --- a/lib/Tmdb/Factory/PeopleFactory.php +++ b/lib/Tmdb/Factory/PeopleFactory.php @@ -13,12 +13,9 @@ namespace Tmdb\Factory; use Tmdb\Common\ObjectHydrator; -use Tmdb\Factory\People\CastFactory; -use Tmdb\Factory\People\CrewFactory; use Tmdb\Model\Collection\People\Cast; use Tmdb\Model\Collection\People\Crew; use Tmdb\Model\Collection\People; -use Tmdb\Model\Common\GenericCollection; use Tmdb\Model\Person\CastMember; use Tmdb\Model\Person\CrewMember; use Tmdb\Model\Person; @@ -29,16 +26,6 @@ class PeopleFactory extends AbstractFactory { */ private $imageFactory; - /** - * @var People\CastFactory - */ - private $castFactory; - - /** - * @var People\CrewFactory - */ - private $crewFactory; - /** * Constructor */ @@ -66,16 +53,16 @@ public function create(array $data = array(), Person\AbstractMember $person = nu } } + if (array_key_exists('profile_path', $data)) { + $person->setProfile($this->getImageFactory()->createFromPath($data['profile_path'], 'profile_path')); + } + if ($person instanceof Person) { /** Images */ if (array_key_exists('images', $data)) { $person->setImages($this->getImageFactory()->createCollectionFromPeople($data['images'])); } - if (array_key_exists('profile_path', $data)) { - $person->setProfile($this->getImageFactory()->createFromPath($data['profile_path'], 'profile_path')); - } - /** Credits */ $this->applyCredits($data, $person); } diff --git a/lib/Tmdb/Model/Movie.php b/lib/Tmdb/Model/Movie.php index a6a183df..e8328b76 100644 --- a/lib/Tmdb/Model/Movie.php +++ b/lib/Tmdb/Model/Movie.php @@ -698,7 +698,7 @@ public function setAlternativeTitles($alternativeTitles) } /** - * @return AlternativeTitle[] + * @return GenericCollection|AlternativeTitle[] */ public function getAlternativeTitles() {