Skip to content

Commit

Permalink
Fixing up profile_path hydration.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 5, 2014
1 parent 20efc1c commit 0790840
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
8 changes: 6 additions & 2 deletions examples/movies/model/all.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() . "<br/>";

Expand All @@ -49,7 +53,7 @@

echo "Images<br/>";

// 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; }
Expand Down
21 changes: 4 additions & 17 deletions lib/Tmdb/Factory/PeopleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,16 +26,6 @@ class PeopleFactory extends AbstractFactory {
*/
private $imageFactory;

/**
* @var People\CastFactory
*/
private $castFactory;

/**
* @var People\CrewFactory
*/
private $crewFactory;

/**
* Constructor
*/
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Tmdb/Model/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ public function setAlternativeTitles($alternativeTitles)
}

/**
* @return AlternativeTitle[]
* @return GenericCollection|AlternativeTitle[]
*/
public function getAlternativeTitles()
{
Expand Down

0 comments on commit 0790840

Please sign in to comment.