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