@@ 24-47 (lines=24) @@ | ||
21 | * |
|
22 | * @return \Psr\Http\Message\ResponseInterface|BuildInfo[]|BuildStream |
|
23 | */ |
|
24 | public function build($inputStream, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
25 | { |
|
26 | $response = parent::build($inputStream, $parameters, self::FETCH_RESPONSE); |
|
27 | ||
28 | if (200 === $response->getStatusCode()) { |
|
29 | if (self::FETCH_STREAM === $fetch) { |
|
30 | return new BuildStream($response->getBody(), $this->serializer); |
|
31 | } |
|
32 | ||
33 | if (self::FETCH_OBJECT === $fetch) { |
|
34 | $buildInfoList = []; |
|
35 | ||
36 | $stream = new BuildStream($response->getBody(), $this->serializer); |
|
37 | $stream->onFrame(function (BuildInfo $buildInfo) use (&$buildInfoList) { |
|
38 | $buildInfoList[] = $buildInfo; |
|
39 | }); |
|
40 | $stream->wait(); |
|
41 | ||
42 | return $buildInfoList; |
|
43 | } |
|
44 | } |
|
45 | ||
46 | return $response; |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * {@inheritdoc} |
|
@@ 54-77 (lines=24) @@ | ||
51 | * |
|
52 | * @return \Psr\Http\Message\ResponseInterface|CreateImageInfo[]|CreateImageStream |
|
53 | */ |
|
54 | public function create($parameters = [], $fetch = self::FETCH_OBJECT) |
|
55 | { |
|
56 | $response = parent::create($parameters, self::FETCH_RESPONSE); |
|
57 | ||
58 | if (200 === $response->getStatusCode()) { |
|
59 | if (self::FETCH_STREAM === $fetch) { |
|
60 | return new CreateImageStream($response->getBody(), $this->serializer); |
|
61 | } |
|
62 | ||
63 | if (self::FETCH_OBJECT === $fetch) { |
|
64 | $createImageInfoList = []; |
|
65 | ||
66 | $stream = new CreateImageStream($response->getBody(), $this->serializer); |
|
67 | $stream->onFrame(function (CreateImageInfo $createImageInfo) use (&$createImageInfoList) { |
|
68 | $createImageInfoList[] = $createImageInfo; |
|
69 | }); |
|
70 | $stream->wait(); |
|
71 | ||
72 | return $createImageInfoList; |
|
73 | } |
|
74 | } |
|
75 | ||
76 | return $response; |
|
77 | } |
|
78 | ||
79 | /** |
|
80 | * {@inheritdoc} |
@@ 16-39 (lines=24) @@ | ||
13 | /** |
|
14 | * {@inheritdoc} |
|
15 | */ |
|
16 | public function getEvents($parameters = [], $fetch = self::FETCH_OBJECT) |
|
17 | { |
|
18 | $response = parent::getEvents($parameters, self::FETCH_RESPONSE); |
|
19 | ||
20 | if (200 === $response->getStatusCode()) { |
|
21 | if (self::FETCH_STREAM === $fetch) { |
|
22 | return new EventStream($response->getBody(), $this->serializer); |
|
23 | } |
|
24 | ||
25 | if (self::FETCH_OBJECT === $fetch) { |
|
26 | $eventList = []; |
|
27 | ||
28 | $stream = new EventStream($response->getBody(), $this->serializer); |
|
29 | $stream->onFrame(function (Event $event) use (&$eventList) { |
|
30 | $eventList[] = $event; |
|
31 | }); |
|
32 | $stream->wait(); |
|
33 | ||
34 | return $eventList; |
|
35 | } |
|
36 | } |
|
37 | ||
38 | return $response; |
|
39 | } |
|
40 | } |
|
41 |