public function get() { if (!is_null($this->id) && count($this->data) == 0) { $this->data = $this->client->call($this->getBaseUri()); } return $this->data; }
/** * Get current data * @return array */ public function get() { $uri = null; if ($this->context) { $uri = $this->context->getBaseUri() . '/'; } $uri .= $this->params['endpoint']; $uri .= sprintf("?page=%d&perpage=%d", $this->page, $this->perpage); // add filter if value is not empty foreach ($this->filters as $filter) { if (!empty($filter['value'])) { $uri .= sprintf("&%s=%s", $filter['field'], rawurlencode($filter['value'])); } } $res = $this->client->call($uri); // get and preserve pagination $lr = Client::getLastResponse(); $this->pagination = isset($lr['body']) && isset($lr['body']['pagination']) ? $lr['body']['pagination'] : []; // convert array to Entities collection $this->data = []; foreach ($res as $data) { $this->data[] = (new Entity([], $this->client))->setData($data); } $this->current = 0; return $this->data; }