1 | <?php |
||
29 | class RestAdapterBuilder |
||
30 | { |
||
31 | /** |
||
32 | * Gets the http client that's available |
||
33 | * |
||
34 | * @var ClientProvider |
||
35 | */ |
||
36 | private $clientProvider; |
||
37 | |||
38 | /** |
||
39 | * Client base url |
||
40 | * |
||
41 | * @var string $baseUrl |
||
42 | */ |
||
43 | private $baseUrl; |
||
44 | |||
45 | /** |
||
46 | * JMS Serializer |
||
47 | * |
||
48 | * @var SerializerInterface $serializer |
||
49 | */ |
||
50 | private $serializer; |
||
51 | |||
52 | /** |
||
53 | * Symfony event dispatcher |
||
54 | * |
||
55 | * @var EventDispatcherInterface |
||
56 | */ |
||
57 | private $eventDispatcher; |
||
58 | |||
59 | /** |
||
60 | * Array of event subscribers |
||
61 | * |
||
62 | * @var EventSubscriberInterface[] |
||
63 | */ |
||
64 | private $subscribers = []; |
||
65 | |||
66 | /** |
||
67 | * Determine if we should use the default log subscriber |
||
68 | */ |
||
69 | private $useLogSubscriber = true; |
||
70 | |||
71 | /** |
||
72 | * Psr logger |
||
73 | * |
||
74 | * @var LoggerInterface |
||
75 | */ |
||
76 | private $logger; |
||
77 | |||
78 | /** |
||
79 | * Constructor |
||
80 | * |
||
81 | * @param ClientProvider $clientProvider |
||
82 | */ |
||
83 | public function __construct(ClientProvider $clientProvider) |
||
87 | |||
88 | |||
89 | /** |
||
90 | * Sets the base url for the rest client |
||
91 | * |
||
92 | * @param string $baseUrl |
||
93 | * @return $this |
||
94 | */ |
||
95 | public function setBaseUrl($baseUrl) |
||
101 | |||
102 | /** |
||
103 | * Sets the http client used with rest client |
||
104 | * |
||
105 | * Currently only supports guzzle clients |
||
106 | * |
||
107 | * @deprecated Will be removed in v3. Use setClientAdapter() instead. |
||
108 | * @param mixed $httpClient |
||
109 | * @return $this |
||
110 | */ |
||
111 | public function setHttpClient($httpClient) |
||
117 | |||
118 | /** |
||
119 | * Set the http client adapter to make requests |
||
120 | * |
||
121 | * @param HttpClientAdapter $clientAdapter |
||
122 | * @return $this |
||
123 | * @throws RetrofitException |
||
124 | */ |
||
125 | public function setClientAdapter(HttpClientAdapter $clientAdapter) |
||
131 | |||
132 | /** |
||
133 | * Set the serializer used with rest client |
||
134 | * |
||
135 | * @param SerializerInterface $serializer |
||
136 | * @return $this |
||
137 | */ |
||
138 | public function setSerializer(SerializerInterface $serializer) |
||
144 | |||
145 | /** |
||
146 | * Set the event dispatcher |
||
147 | * |
||
148 | * @param EventDispatcherInterface $eventDispatcher |
||
149 | * @return RestAdapterBuilder |
||
150 | */ |
||
151 | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher) |
||
157 | |||
158 | /** |
||
159 | * Add a subscriber |
||
160 | * |
||
161 | * @param EventSubscriberInterface $subscriber |
||
162 | * @return $this |
||
163 | */ |
||
164 | public function addSubscriber(EventSubscriberInterface $subscriber) |
||
170 | |||
171 | /** |
||
172 | * Do not use the default log subscriber; |
||
173 | * |
||
174 | * @return $this |
||
175 | */ |
||
176 | public function ignoreLogSubscriber() |
||
182 | |||
183 | /** |
||
184 | * @param LoggerInterface $logger |
||
185 | * @return $this |
||
186 | */ |
||
187 | public function setLogger($logger) |
||
193 | |||
194 | /** |
||
195 | * Build the rest adapter |
||
196 | * |
||
197 | * @return RestAdapter |
||
198 | * @throws RetrofitException |
||
199 | */ |
||
200 | public function build() |
||
235 | } |
||
236 |