From 99bafae19c8720856ccdb9967ddb8546bff56483 Mon Sep 17 00:00:00 2001 From: slepic Date: Mon, 26 Oct 2020 12:28:44 +0100 Subject: [PATCH] Propagate client instance to all items of array response (#68) --- src/Resource/AbstractResource.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Resource/AbstractResource.php b/src/Resource/AbstractResource.php index f40ea43..781135a 100644 --- a/src/Resource/AbstractResource.php +++ b/src/Resource/AbstractResource.php @@ -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"];