/** * @param array $data * @param object $object * @return object */ public function hydrate(array $data, $object) { if (!isset($data['artists'])) { return $object; } $artistCollection = new ArtistCollection(); foreach ($data['artists'] as $artist) { $artistCollection->add(new Artist($artist)); } $object->setArtists($artistCollection); return $object; }
/** * @param array $data * @param ArtistCollection $object * @return ArtistCollection */ public function hydrate(array $data, $object) { if (!isset($data['artists'])) { return $object; } foreach ($data['artists'] as $artist) { $hydrators = new AggregateHydrator(); $hydrators->add(new ArtistHydrator()); $hydrators->add(new ImageCollectionAwareHydrator()); $object->add($hydrators->hydrate($artist, new Artist())); } return $object; }