1 | <?php |
||
11 | trait ProviderRedirectTrait |
||
12 | { |
||
13 | /** |
||
14 | * Maximum number of times to follow provider initiated redirects |
||
15 | * |
||
16 | * @var integer |
||
17 | */ |
||
18 | protected $redirectLimit = 2; |
||
19 | |||
20 | /** |
||
21 | * Retrieves a response for a given request and retrieves subsequent |
||
22 | * responses, with authorization headers, if a redirect is detected. |
||
23 | * |
||
24 | * @param RequestInterface $request |
||
25 | * @return ResponseInterface |
||
26 | * @throws BadResponseException |
||
27 | */ |
||
28 | 8 | protected function followRequestRedirects(RequestInterface $request) |
|
49 | |||
50 | /** |
||
51 | * Returns the HTTP client instance. |
||
52 | * |
||
53 | * @return GuzzleHttp\ClientInterface |
||
54 | */ |
||
55 | abstract public function getHttpClient(); |
||
56 | |||
57 | /** |
||
58 | * Retrieves current redirect limit. |
||
59 | * |
||
60 | * @return integer |
||
61 | */ |
||
62 | 4 | public function getRedirectLimit() |
|
66 | |||
67 | /** |
||
68 | * Determines if a given response is a redirect. |
||
69 | * |
||
70 | * @param ResponseInterface $response |
||
71 | * |
||
72 | * @return boolean |
||
73 | */ |
||
74 | 6 | protected function isRedirect(ResponseInterface $response) |
|
80 | |||
81 | /** |
||
82 | * Sends a request instance and returns a response instance. |
||
83 | * |
||
84 | * WARNING: This method does not attempt to catch exceptions caused by HTTP |
||
85 | * errors! It is recommended to wrap this method in a try/catch block. |
||
86 | * |
||
87 | * @param RequestInterface $request |
||
88 | * @return ResponseInterface |
||
89 | */ |
||
90 | 8 | public function getResponse(RequestInterface $request) |
|
100 | |||
101 | /** |
||
102 | * Updates the redirect limit. |
||
103 | * |
||
104 | * @param integer $limit |
||
105 | * @return League\OAuth2\Client\Provider\AbstractProvider |
||
106 | * @throws InvalidArgumentException |
||
107 | */ |
||
108 | 14 | public function setRedirectLimit($limit) |
|
122 | } |
||
123 |