Skip to content

Commit

Permalink
Fixing an issue where an Image object should be present but it was not.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Mar 23, 2014
1 parent 9144b4d commit c900d2f
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions lib/Tmdb/Factory/PeopleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@

use Tmdb\Common\ObjectHydrator;
use Tmdb\Factory\Common\ChangeFactory;
use Tmdb\Model\Collection\People\Cast;
use Tmdb\Model\Collection\People\Crew;
use Tmdb\Model\Collection\People;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Person\CastMember;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Model\Person;

/**
* Class PeopleFactory
* @package Tmdb\Factory
*/
class PeopleFactory extends AbstractFactory
{
/**
Expand Down Expand Up @@ -51,7 +49,7 @@ public function __construct()
*
* @return Person|CrewMember|CastMember
*/
public function create(array $data = array(), $person = null)
public function create(array $data = array(), Person\AbstractMember $person = null)
{
if (!is_object($person)) {
if (array_key_exists('character', $data)) {
Expand Down Expand Up @@ -101,7 +99,7 @@ public function create(array $data = array(), $person = null)
* @param array $data
* @param Person $person
*/
protected function applyCredits(array $data, Person $person)
protected function applyCredits(array $data = array(), Person $person)
{
$hydrator = new ObjectHydrator();
$types = array('movie_credits', 'tv_credits', 'combined_credits');
Expand All @@ -117,7 +115,7 @@ protected function applyCredits(array $data, Person $person)
);

foreach ($cast as $member) {
$member->setPosterImage($member->getPosterPath());
$member->setPosterImage($this->getPosterImageForCredit($member->getPosterPath()));
}

$person->$method()->setCast($cast);
Expand All @@ -130,7 +128,7 @@ protected function applyCredits(array $data, Person $person)
);

foreach ($crew as $member) {
$member->setPosterImage($member->getPosterPath());
$member->setPosterImage($this->getPosterImageForCredit($member->getPosterPath()));
}

$person->$method()->setCrew($crew);
Expand All @@ -147,7 +145,7 @@ protected function getPosterImageForCredit($posterPath)
/**
* {@inheritdoc}
*/
public function createCollection(array $data = array(), $person = null, $collection = null)
public function createCollection(array $data = array(), Person\AbstractMember $person = null, $collection = null)
{
if (!$collection) {
$collection = new People();
Expand All @@ -157,11 +155,7 @@ public function createCollection(array $data = array(), $person = null, $collect
$data = $data['results'];
}

if (is_object($person)) {
$class = get_class($person);
} else {
$class = '\Tmdb\Model\Person';
}
$class = get_class($person);

foreach ($data as $item) {
$collection->add(null, $this->create($item, new $class()));
Expand Down

0 comments on commit c900d2f

Please sign in to comment.