1 | <?php |
||
30 | class RestAdapterBuilder |
||
31 | { |
||
32 | /** |
||
33 | * Gets the http client that's available |
||
34 | * |
||
35 | * @var ClientProvider |
||
36 | */ |
||
37 | private $clientProvider; |
||
38 | |||
39 | /** |
||
40 | * Client base url |
||
41 | * |
||
42 | * @var string $baseUrl |
||
43 | */ |
||
44 | private $baseUrl; |
||
45 | |||
46 | /** |
||
47 | * JMS Serializer |
||
48 | * |
||
49 | * @var Serializer $serializer |
||
50 | */ |
||
51 | private $serializer; |
||
52 | |||
53 | /** |
||
54 | * Symfony event dispatcher |
||
55 | * |
||
56 | * @var EventDispatcherInterface |
||
57 | */ |
||
58 | private $eventDispatcher; |
||
59 | |||
60 | /** |
||
61 | * Array of event subscribers |
||
62 | * |
||
63 | * @var EventSubscriberInterface[] |
||
64 | */ |
||
65 | private $subscribers = []; |
||
66 | |||
67 | /** |
||
68 | * Determine if we should use the default log subscriber |
||
69 | */ |
||
70 | private $useLogSubscriber = true; |
||
71 | |||
72 | /** |
||
73 | * Psr logger |
||
74 | * |
||
75 | * @var LoggerInterface |
||
76 | */ |
||
77 | private $logger; |
||
78 | |||
79 | /** |
||
80 | * Constructor |
||
81 | * |
||
82 | * @param ClientProvider $clientProvider |
||
83 | */ |
||
84 | public function __construct(ClientProvider $clientProvider) |
||
88 | |||
89 | |||
90 | /** |
||
91 | * Sets the base url for the rest client |
||
92 | * |
||
93 | * @param string $baseUrl |
||
94 | * @return $this |
||
95 | */ |
||
96 | public function setBaseUrl($baseUrl) |
||
102 | |||
103 | /** |
||
104 | * Sets the http client used with rest client |
||
105 | * |
||
106 | * Currently only supports guzzle clients |
||
107 | * |
||
108 | * @deprecated Will be removed in v3. Use setClientAdapter() instead. |
||
109 | * @param mixed $httpClient |
||
110 | * @return $this |
||
111 | * @throws RetrofitException |
||
112 | */ |
||
113 | public function setHttpClient($httpClient) |
||
125 | |||
126 | /** |
||
127 | * Set the http client adapter to make requests |
||
128 | * |
||
129 | * @param HttpClientAdapter $clientAdapter |
||
130 | * @return $this |
||
131 | * @throws RetrofitException |
||
132 | */ |
||
133 | public function setClientAdapter(HttpClientAdapter $clientAdapter) |
||
139 | |||
140 | /** |
||
141 | * Set the serializer used with rest client |
||
142 | * |
||
143 | * @param Serializer $serializer |
||
144 | * @return $this |
||
145 | */ |
||
146 | public function setSerializer(Serializer $serializer) |
||
152 | |||
153 | /** |
||
154 | * Set the event dispatcher |
||
155 | * |
||
156 | * @param EventDispatcherInterface $eventDispatcher |
||
157 | * @return RestAdapterBuilder |
||
158 | */ |
||
159 | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher) |
||
165 | |||
166 | /** |
||
167 | * Add a subscriber |
||
168 | * |
||
169 | * @param EventSubscriberInterface $subscriber |
||
170 | * @return $this |
||
171 | */ |
||
172 | public function addSubscriber(EventSubscriberInterface $subscriber) |
||
178 | |||
179 | /** |
||
180 | * Do not use the default log subscriber; |
||
181 | * |
||
182 | * @return $this |
||
183 | */ |
||
184 | public function ignoreLogSubscriber() |
||
190 | |||
191 | /** |
||
192 | * @param LoggerInterface $logger |
||
193 | * @return $this |
||
194 | */ |
||
195 | public function setLogger(LoggerInterface $logger) |
||
201 | |||
202 | /** |
||
203 | * Build the rest adapter |
||
204 | * |
||
205 | * @return RestAdapter |
||
206 | * @throws RetrofitException |
||
207 | */ |
||
208 | public function build() |
||
249 | } |
||
250 |