/** * Получает информацию * * @return array */ public function getContents() { if (!parent::getContents() or $this->previous_params && $this->previous_params != $this->request_params) { parent::__construct(call_user_func($this->closure, $this->request_params), true); $this->previous_params = $this->request_params; } return parent::getContents(); }
/** * Получает информацию о ресурсе * * @return mixed */ public function getContents() { if (!parent::getContents() || $this->previous_params && $this->previous_params != $this->request_params) { $response = $this->request->get($this->parent_disk->getRequestUrl('resources', array_merge($this->request_params, array('path' => $this->resource_path)))); $this->previous_params = $this->request_params; if (isset($response['type'])) { $this->resource_type = $response['type']; } if (isset($response['_embedded'], $response['_embedded']['items'])) { $response += ['items' => array_map(function ($item) { return new self($item, $this->parent_disk, $this->request); }, $response['_embedded']['items'])] + $response['_embedded']; } unset($response['_links'], $response['_embedded']); parent::__construct($response); } return parent::getContents(); }
/** * Получает информацию о ресурсе * * @return mixed */ public function getContents() { if (!parent::getContents() or $this->previous_params != $this->request_params) { $this->previous_params = $this->request_params; $response = $this->request->get($this->parent_disk->getRequestUrl('public/resources', array_merge($this->request_params, ['public_key' => $this->getPublicKey()]))); if (isset($response['type'])) { $this->resource_type = $response['type']; } if (isset($response['_embedded'], $response['_embedded']['items'])) { $response['items'] = array_map(function ($item) { return new self($item, $this->parent_disk, $this->request); }, $response['_embedded']['items']); } unset($response['_links'], $response['_embedded']); parent::__construct($response); } return parent::getContents(); }