Skip to content

Commit 1d41bf2

Browse files
authored
fix getContentType by allowing options to be passed through (including async) (#25)
1 parent 3a12dc8 commit 1d41bf2

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

src/Contentful.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,25 +217,9 @@ public function getContentType($id, $space = null, array $options = [])
217217
if ($this->envelope->hasContentType($id)) {
218218
return $this->envelope->findContentType($id);
219219
}
220-
$spaceName = ($space instanceof SpaceInterface) ? $space->getName() : $space;
221-
$spaceData = $this->getSpaceDataForName(($space instanceof SpaceInterface) ? $space->getName() : $space);
222-
$api = ($spaceData['preview_mode']) ? self::PREVIEW_API : self::CONTENT_DELIVERY_API;
223220

224-
if ($options) {
225-
return $this->doRequest(
226-
$spaceData,
227-
$spaceName,
228-
$this->getEndpointUrl(sprintf('/spaces/%s/content_types/%s', $spaceData['key'], $id), $api),
229-
sprintf('The content type with ID "%s" from the space "%s" was unavailable.', $id, $spaceName),
230-
$api,
231-
'content_type',
232-
strval($id),
233-
[],
234-
$options
235-
);
236-
}
237221
//fetch them all and pick one out, as it is likely we'll want to access others
238-
$contentTypes = $this->getContentTypes([], $space);
222+
$contentTypes = $this->getContentTypes([], $space, $options);
239223
foreach ($contentTypes as $contentType) {
240224
$this->envelope->insertContentType($contentType);
241225
}

0 commit comments

Comments
 (0)