Skip to content

Commit

Permalink
Propagate client instance to all items of array response (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
slepic authored Oct 26, 2020
1 parent a11347d commit 99bafae
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Resource/AbstractResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public function setClient(ClientInterface $client)
public static function fromArray(array $data, ClientInterface $client = null)
{
if (isset($data[static::ROOT_KEY])) {
$array = new ArrayCollection(array_map([static::class, 'fromArray'], $data[static::ROOT_KEY]));
$array = new ArrayCollection(array_map(function ($data) use ($client) {
return static::fromArray($data, $client);
}, $data[static::ROOT_KEY]));
// The following are subject to change soon, so they are optional.
if (isset($data["current_page"])) {
$array->current_page = $data["current_page"];
Expand Down

0 comments on commit 99bafae

Please sign in to comment.