/** * @param string $id * * @return EntryInterface * * @api */ public function getEntry($id) { if ($this->instanceCache->hasEntry($id)) { return $this->instanceCache->getEntry($id); } return $this->requestAndBuild('GET', 'entries/' . $id, ['query' => ['locale' => '*']]); }
/** * When an instance of the target already exists, it is returned. If not, a Link is created as placeholder. * * @param object $data * * @return Asset|DynamicEntry|Link * * @throws \InvalidArgumentException When encountering an unexpected link type. Only links to assets and entries are currently handled. */ private function buildLink($data) { $id = $data->sys->id; $type = $data->sys->linkType; if ($type === 'Asset') { if ($this->instanceCache->hasAsset($id)) { return $this->instanceCache->getAsset($id); } return new Link($id, $type); } if ($type === 'Entry') { if ($this->instanceCache->hasEntry($id)) { return $this->instanceCache->getEntry($id); } return new Link($id, $type); } throw new \InvalidArgumentException('Encountered unexpected resource type "' . $type . '"" while constructing link.'); }