X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fseekat;a=blobdiff_plain;f=lib%2FAPI%2FCall.php;fp=lib%2FAPI%2FCall.php;h=7eba2a80b7fbfb76f6b7748c728c06797410c357;hp=ba51ca3fe23dbe2d74ef60a2b3bc9afe6974bf00;hb=e368287b3cd2dd40945ac8d1a1946bc32268007d;hpb=f4aa6beaf2e1f0dc9c877782cbbad5a989194517 diff --git a/lib/API/Call.php b/lib/API/Call.php index ba51ca3..7eba2a8 100644 --- a/lib/API/Call.php +++ b/lib/API/Call.php @@ -25,26 +25,11 @@ final class Call } function __invoke(array $args) : Promise { - $promise = $this->api->{$this->call}->get(...$args); - - /* fetch resource, unless already localized, and try for {$method}_url */ - if (!$this->api->exists($this->call)) { - $promise->when(function($error, $value) use($args) { - if (!isset($error)) { - return $value; - } - if ($this->api->exists($this->call."_url", $url)) { - $url = new Url(uri_template($url, (array)current($args))); - return $this->api->withUrl($url)->get(...$args); - } - - $message = Exception\message($error); - $this->api->getLogger()->error("call($this->call): " . $message, [ - "url" => (string) $this->api->getUrl() - ]); - - throw $error; - }); + if ($this->api->exists($this->call."_url", $url)) { + $url = new Url(uri_template($url, (array)current($args))); + $promise = $this->api->withUrl($url)->get(...$args); + } else { + $promise = $this->api->{$this->call}->get(...$args); } return $promise;