SurrogateInterface.php 2.3 KB

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