1 | <?php |
||
33 | class RestAdapterBuilder |
||
34 | { |
||
35 | /** |
||
36 | * Gets the http client that's available |
||
37 | * |
||
38 | * @var ClientProvider |
||
39 | */ |
||
40 | private $clientProvider; |
||
41 | |||
42 | /** |
||
43 | * Client base url |
||
44 | * |
||
45 | * @var string $baseUrl |
||
46 | */ |
||
47 | private $baseUrl; |
||
48 | |||
49 | /** |
||
50 | * JMS Serializer |
||
51 | * |
||
52 | * @var Serializer $serializer |
||
53 | */ |
||
54 | private $serializer; |
||
55 | |||
56 | /** |
||
57 | * Serializer adapter |
||
58 | * |
||
59 | * @var SerializerAdapter |
||
60 | */ |
||
61 | private $serializerAdapter; |
||
62 | |||
63 | /** |
||
64 | * Deserializer adapter |
||
65 | * |
||
66 | * @var DeserializerAdapter |
||
67 | */ |
||
68 | private $deserializerAdapter; |
||
69 | |||
70 | /** |
||
71 | * Symfony event dispatcher |
||
72 | * |
||
73 | * @var EventDispatcherInterface |
||
74 | */ |
||
75 | private $eventDispatcher; |
||
76 | |||
77 | /** |
||
78 | * Array of event subscribers |
||
79 | * |
||
80 | * @var EventSubscriberInterface[] |
||
81 | */ |
||
82 | private $subscribers = []; |
||
83 | |||
84 | /** |
||
85 | * Determine if we should use the default log subscriber |
||
86 | */ |
||
87 | private $useLogSubscriber = true; |
||
88 | |||
89 | /** |
||
90 | * Psr logger |
||
91 | * |
||
92 | * @var LoggerInterface |
||
93 | */ |
||
94 | private $logger; |
||
95 | |||
96 | /** |
||
97 | * Constructor |
||
98 | * |
||
99 | * @param ClientProvider $clientProvider |
||
100 | */ |
||
101 | public function __construct(ClientProvider $clientProvider) |
||
105 | |||
106 | |||
107 | /** |
||
108 | * Sets the base url for the rest client |
||
109 | * |
||
110 | * @param string $baseUrl |
||
111 | * @return $this |
||
112 | */ |
||
113 | public function setBaseUrl($baseUrl) |
||
119 | |||
120 | /** |
||
121 | * Sets the http client used with rest client |
||
122 | * |
||
123 | * Currently only supports guzzle clients |
||
124 | * |
||
125 | * @deprecated Will be removed in v3. Use setClientAdapter() instead. |
||
126 | * @param mixed $httpClient |
||
127 | * @return $this |
||
128 | * @throws RetrofitException |
||
129 | */ |
||
130 | public function setHttpClient($httpClient) |
||
142 | |||
143 | /** |
||
144 | * Set the http client adapter to make requests |
||
145 | * |
||
146 | * @param HttpClientAdapter $clientAdapter |
||
147 | * @return $this |
||
148 | * @throws RetrofitException |
||
149 | */ |
||
150 | public function setClientAdapter(HttpClientAdapter $clientAdapter) |
||
156 | |||
157 | /** |
||
158 | * Set the serializer used with rest client |
||
159 | * |
||
160 | * @param Serializer $serializer |
||
161 | * @return $this |
||
162 | */ |
||
163 | public function setSerializer(Serializer $serializer) |
||
176 | |||
177 | /** |
||
178 | * Set the serializer adapter |
||
179 | * |
||
180 | * @param SerializerAdapter $serializerAdapter |
||
181 | * @return $this |
||
182 | */ |
||
183 | public function setSerializerAdapter(SerializerAdapter $serializerAdapter) |
||
189 | |||
190 | /** |
||
191 | * Set the deserializer adapter |
||
192 | * |
||
193 | * @param DeserializerAdapter $deserializerAdapter |
||
194 | * @return $this |
||
195 | */ |
||
196 | public function setDeserializerAdapter(DeserializerAdapter $deserializerAdapter) |
||
202 | |||
203 | /** |
||
204 | * Set the event dispatcher |
||
205 | * |
||
206 | * @param EventDispatcherInterface $eventDispatcher |
||
207 | * @return RestAdapterBuilder |
||
208 | */ |
||
209 | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher) |
||
215 | |||
216 | /** |
||
217 | * Add a subscriber |
||
218 | * |
||
219 | * @param EventSubscriberInterface $subscriber |
||
220 | * @return $this |
||
221 | */ |
||
222 | public function addSubscriber(EventSubscriberInterface $subscriber) |
||
228 | |||
229 | /** |
||
230 | * Do not use the default log subscriber; |
||
231 | * |
||
232 | * @return $this |
||
233 | */ |
||
234 | public function ignoreLogSubscriber() |
||
240 | |||
241 | /** |
||
242 | * @param LoggerInterface $logger |
||
243 | * @return $this |
||
244 | */ |
||
245 | public function setLogger(LoggerInterface $logger) |
||
251 | |||
252 | /** |
||
253 | * Build the rest adapter |
||
254 | * |
||
255 | * @return RestAdapter |
||
256 | * @throws RetrofitException |
||
257 | */ |
||
258 | public function build() |
||
301 | } |
||
302 |