ResponsePolicyInterface.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Drupal\Core\PageCache;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\Response;
  5. /**
  6. * Defines the interface for response policy implementations.
  7. *
  8. * The response policy is evaluated in order to determine whether a page should
  9. * be stored a in the cache. Calling code should do so unless static::DENY is
  10. * returned from the check() method.
  11. */
  12. interface ResponsePolicyInterface {
  13. /**
  14. * Deny storage of a page in the cache.
  15. */
  16. const DENY = 'deny';
  17. /**
  18. * Determines whether it is save to store a page in the cache.
  19. *
  20. * @param \Symfony\Component\HttpFoundation\Response $response
  21. * The response which is about to be sent to the client.
  22. * @param \Symfony\Component\HttpFoundation\Request $request
  23. * The request object.
  24. *
  25. * @return string|null
  26. * Either static::DENY or NULL. Calling code may attempt to store a page in
  27. * the cache unless static::DENY is returned. Returns NULL if the policy
  28. * policy is not specified for the given response.
  29. */
  30. public function check(Response $response, Request $request);
  31. }