Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\HttpKernel\HttpCache;
|
Chris@0
|
13
|
Chris@0
|
14 use Symfony\Component\HttpFoundation\Request;
|
Chris@0
|
15 use Symfony\Component\HttpFoundation\Response;
|
Chris@0
|
16
|
Chris@0
|
17 interface SurrogateInterface
|
Chris@0
|
18 {
|
Chris@0
|
19 /**
|
Chris@0
|
20 * Returns surrogate name.
|
Chris@0
|
21 *
|
Chris@0
|
22 * @return string
|
Chris@0
|
23 */
|
Chris@0
|
24 public function getName();
|
Chris@0
|
25
|
Chris@0
|
26 /**
|
Chris@0
|
27 * Returns a new cache strategy instance.
|
Chris@0
|
28 *
|
Chris@0
|
29 * @return ResponseCacheStrategyInterface A ResponseCacheStrategyInterface instance
|
Chris@0
|
30 */
|
Chris@0
|
31 public function createCacheStrategy();
|
Chris@0
|
32
|
Chris@0
|
33 /**
|
Chris@0
|
34 * Checks that at least one surrogate has Surrogate capability.
|
Chris@0
|
35 *
|
Chris@0
|
36 * @param Request $request A Request instance
|
Chris@0
|
37 *
|
Chris@0
|
38 * @return bool true if one surrogate has Surrogate capability, false otherwise
|
Chris@0
|
39 */
|
Chris@0
|
40 public function hasSurrogateCapability(Request $request);
|
Chris@0
|
41
|
Chris@0
|
42 /**
|
Chris@0
|
43 * Adds Surrogate-capability to the given Request.
|
Chris@0
|
44 *
|
Chris@0
|
45 * @param Request $request A Request instance
|
Chris@0
|
46 */
|
Chris@0
|
47 public function addSurrogateCapability(Request $request);
|
Chris@0
|
48
|
Chris@0
|
49 /**
|
Chris@0
|
50 * Adds HTTP headers to specify that the Response needs to be parsed for Surrogate.
|
Chris@0
|
51 *
|
Chris@0
|
52 * This method only adds an Surrogate HTTP header if the Response has some Surrogate tags.
|
Chris@0
|
53 *
|
Chris@0
|
54 * @param Response $response A Response instance
|
Chris@0
|
55 */
|
Chris@0
|
56 public function addSurrogateControl(Response $response);
|
Chris@0
|
57
|
Chris@0
|
58 /**
|
Chris@0
|
59 * Checks that the Response needs to be parsed for Surrogate tags.
|
Chris@0
|
60 *
|
Chris@0
|
61 * @param Response $response A Response instance
|
Chris@0
|
62 *
|
Chris@0
|
63 * @return bool true if the Response needs to be parsed, false otherwise
|
Chris@0
|
64 */
|
Chris@0
|
65 public function needsParsing(Response $response);
|
Chris@0
|
66
|
Chris@0
|
67 /**
|
Chris@0
|
68 * Renders a Surrogate tag.
|
Chris@0
|
69 *
|
Chris@0
|
70 * @param string $uri A URI
|
Chris@0
|
71 * @param string $alt An alternate URI
|
Chris@0
|
72 * @param bool $ignoreErrors Whether to ignore errors or not
|
Chris@0
|
73 * @param string $comment A comment to add as an esi:include tag
|
Chris@0
|
74 *
|
Chris@0
|
75 * @return string
|
Chris@0
|
76 */
|
Chris@0
|
77 public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '');
|
Chris@0
|
78
|
Chris@0
|
79 /**
|
Chris@0
|
80 * Replaces a Response Surrogate tags with the included resource content.
|
Chris@0
|
81 *
|
Chris@0
|
82 * @param Request $request A Request instance
|
Chris@0
|
83 * @param Response $response A Response instance
|
Chris@0
|
84 *
|
Chris@0
|
85 * @return Response
|
Chris@0
|
86 */
|
Chris@0
|
87 public function process(Request $request, Response $response);
|
Chris@0
|
88
|
Chris@0
|
89 /**
|
Chris@0
|
90 * Handles a Surrogate from the cache.
|
Chris@0
|
91 *
|
Chris@0
|
92 * @param HttpCache $cache An HttpCache instance
|
Chris@0
|
93 * @param string $uri The main URI
|
Chris@0
|
94 * @param string $alt An alternative URI
|
Chris@0
|
95 * @param bool $ignoreErrors Whether to ignore errors or not
|
Chris@0
|
96 *
|
Chris@0
|
97 * @return string
|
Chris@0
|
98 *
|
Chris@0
|
99 * @throws \RuntimeException
|
Chris@0
|
100 * @throws \Exception
|
Chris@0
|
101 */
|
Chris@0
|
102 public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors);
|
Chris@0
|
103 }
|