1 | <?php |
||
9 | class PrerenderClient extends GoutteClient |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $prerenderUrl; |
||
15 | |||
16 | /** |
||
17 | * @param string $prerenderUrl The url of the prerender server |
||
18 | * @param array $server The server parameters (equivalent of $_SERVER) |
||
19 | * @param History $history A History instance to store the browser history |
||
20 | * @param CookieJar $cookieJar A CookieJar instance to store the cookies |
||
21 | */ |
||
22 | 4 | public function __construct($prerenderUrl, array $server = [], History $history = null, CookieJar $cookieJar = null) |
|
28 | |||
29 | /** |
||
30 | * @param string $uri |
||
31 | * @return string |
||
32 | */ |
||
33 | 2 | protected function getAbsoluteUri($uri) |
|
37 | |||
38 | /** |
||
39 | * @inheritdoc |
||
40 | */ |
||
41 | 2 | public function getRequest() |
|
42 | { |
||
43 | 2 | $request = parent::getRequest(); |
|
44 | 2 | if (!empty($request)) { |
|
45 | 1 | return new Request($this->correctUrl($request->getUri()), |
|
46 | 1 | $request->getMethod(), $request->getParameters(), |
|
47 | 1 | $request->getFiles(), $request->getCookies(), $request->getServer(), |
|
48 | 1 | $request->getContent()); |
|
49 | } |
||
50 | 1 | } |
|
51 | |||
52 | /** |
||
53 | * @param $url |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 1 | protected function correctUrl($url) |
|
61 | } |
||
62 |