/** * @param string $id * * @return ContentType * * @api */ public function getContentType($id) { if ($this->instanceCache->hasContentType($id)) { return $this->instanceCache->getContentType($id); } return $this->requestAndBuild('GET', 'content_types/' . $id); }
/** * Creates a ContentType. * * @param object $data * * @return ContentType|null */ private function buildContentType($data) { if ($this->instanceCache->hasContentType($data->sys->id)) { return $this->instanceCache->getContentType($data->sys->id); } $sys = $this->buildSystemProperties($data->sys); $fields = array_map([$this, 'buildContentTypeField'], $data->fields); $displayField = isset($data->displayField) ? $data->displayField : null; $contentType = new ContentType($data->name, isset($data->description) ? $data->description : null, $fields, $displayField, $sys); $this->instanceCache->addContentType($contentType); return $contentType; }