18
18
use Markup \Contentful \Log \LogInterface ;
19
19
use Markup \Contentful \Log \NullLogger ;
20
20
use Markup \Contentful \Log \StandardLogger ;
21
+ use Markup \Contentful \Promise \AssetPromise ;
22
+ use Markup \Contentful \Promise \ContentTypePromise ;
23
+ use Markup \Contentful \Promise \EntryPromise ;
24
+ use Markup \Contentful \Promise \ResourceArrayPromise ;
25
+ use Markup \Contentful \Promise \SpacePromise ;
21
26
use Psr \Cache \CacheItemInterface ;
22
27
use Psr \Cache \CacheItemPoolInterface ;
23
28
use Psr \Http \Message \ResponseInterface ;
@@ -125,6 +130,18 @@ public function getSpace($space = null, array $options = [])
125
130
);
126
131
}
127
132
133
+ /**
134
+ * @param string|SpaceInterface $space The space name, or space object.
135
+ * @param array $options
136
+ * @return SpaceInterface|PromiseInterface
137
+ */
138
+ public function getSpaceAsync ($ space = null , array $ options = [])
139
+ {
140
+ return new SpacePromise (
141
+ $ this ->getSpace ($ space , array_merge ($ options , ['async ' => true ]))
142
+ );
143
+ }
144
+
128
145
/**
129
146
* @param string $id
130
147
* @param string|SpaceInterface $space
@@ -156,11 +173,24 @@ public function getEntry($id, $space = null, array $options = [])
156
173
);
157
174
}
158
175
176
+ /**
177
+ * @param string $id
178
+ * @param string|SpaceInterface $space
179
+ * @param array $options
180
+ * @return EntryInterface|PromiseInterface
181
+ */
182
+ public function getEntryAsync ($ id , $ space = null , array $ options = [])
183
+ {
184
+ return new EntryPromise (
185
+ $ this ->getEntry ($ id , $ space , array_merge ($ options , ['async ' => true ]))
186
+ );
187
+ }
188
+
159
189
/**
160
190
* @param ParameterInterface[] $parameters
161
191
* @param string $space
162
192
* @param array $options
163
- * @return ResourceArray |EntryInterface[]|PromiseInterface
193
+ * @return ResourceArrayInterface |EntryInterface[]|PromiseInterface
164
194
* @throws Exception\ResourceUnavailableException
165
195
*/
166
196
public function getEntries (array $ parameters = [], $ space = null , array $ options = [])
@@ -182,6 +212,19 @@ public function getEntries(array $parameters = [], $space = null, array $options
182
212
);
183
213
}
184
214
215
+ /**
216
+ * @param ParameterInterface[] $parameters
217
+ * @param string $space
218
+ * @param array $options
219
+ * @return ResourceArrayInterface|PromiseInterface
220
+ */
221
+ public function getEntriesAsync (array $ parameters = [], $ space = null , array $ options = [])
222
+ {
223
+ return new ResourceArrayPromise (
224
+ $ this ->getEntries ($ parameters , $ space , array_merge ($ options , ['async ' => true ]))
225
+ );
226
+ }
227
+
185
228
/**
186
229
* @param string $id
187
230
* @param string|SpaceInterface $space
@@ -212,6 +255,19 @@ public function getAsset($id, $space = null, array $options = [])
212
255
);
213
256
}
214
257
258
+ /**
259
+ * @param string $id
260
+ * @param string|SpaceInterface $space
261
+ * @param array $options
262
+ * @return AssetInterface|PromiseInterface
263
+ */
264
+ public function getAssetAsync ($ id , $ space = null , array $ options = [])
265
+ {
266
+ return new AssetPromise (
267
+ $ this ->getAsset ($ id , $ space , array_merge ($ options , ['async ' => true ]))
268
+ );
269
+ }
270
+
215
271
/**
216
272
* @param string $id
217
273
* @param string|SpaceInterface $space
@@ -241,6 +297,19 @@ function ($contentTypes) use ($id) {
241
297
return (isset ($ options ['async ' ]) && $ options ['async ' ]) ? $ contentTypesPromise : $ contentTypesPromise ->wait ();
242
298
}
243
299
300
+ /**
301
+ * @param string $id
302
+ * @param string|SpaceInterface $space
303
+ * @param array $options
304
+ * @return ContentTypeInterface|PromiseInterface
305
+ */
306
+ public function getContentTypeAsync ($ id , $ space = null , array $ options = [])
307
+ {
308
+ return new ContentTypePromise (
309
+ $ this ->getContentType ($ id , $ space , array_merge ($ options , ['async ' => true ]))
310
+ );
311
+ }
312
+
244
313
/**
245
314
* @param array $parameters
246
315
* @param string|SpaceInterface $space
@@ -274,6 +343,19 @@ public function getContentTypes(array $parameters = [], $space = null, array $op
274
343
);
275
344
}
276
345
346
+ /**
347
+ * @param array $parameters
348
+ * @param string|SpaceInterface $space
349
+ * @param array $options
350
+ * @return ResourceArray|ContentTypeInterface[]|PromiseInterface
351
+ */
352
+ public function getContentTypesAsync (array $ parameters = [], $ space = null , array $ options = [])
353
+ {
354
+ return new ResourceArrayPromise (
355
+ $ this ->getContentTypes ($ parameters , $ space , array_merge ($ options , ['async ' => true ]))
356
+ );
357
+ }
358
+
277
359
/**
278
360
* Gets a content type using its name. Assumes content types have unique names. Returns null if no content type with the given name can be found.
279
361
*
@@ -307,6 +389,21 @@ function () use ($name, $space, $options) {
307
389
return (isset ($ options ['async ' ]) && $ options ['async ' ]) ? $ promise : $ promise ->wait ();
308
390
}
309
391
392
+ /**
393
+ * Gets a (lazy-fetching) content type using its name. Assumes content types have unique names. Returns null if no content type with the given name can be found.
394
+ *
395
+ * @param string $name
396
+ * @param string|SpaceInterface $space
397
+ * @param array $options
398
+ * @return ContentTypeInterface|PromiseInterface|null
399
+ */
400
+ public function getContentTypeByNameAsync ($ name , $ space = null , array $ options = [])
401
+ {
402
+ return new ContentTypePromise (
403
+ $ this ->getContentTypeByName ($ name , $ space , array_merge ($ options , ['async ' => true ]))
404
+ );
405
+ }
406
+
310
407
/**
311
408
* @param Link $link
312
409
* @param array $options
0 commit comments