DefaultRequestPolicy.php 972 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Drupal\Core\PageCache;
  3. use Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod;
  4. use Drupal\Core\PageCache\RequestPolicy\NoSessionOpen;
  5. use Drupal\Core\Session\SessionConfigurationInterface;
  6. /**
  7. * The default page cache request policy.
  8. *
  9. * Delivery of cached pages is denied if either the application is running from
  10. * the command line or the request was not initiated with a safe method (GET or
  11. * HEAD). Also caching is only allowed for requests without a session cookie.
  12. */
  13. class DefaultRequestPolicy extends ChainRequestPolicy {
  14. /**
  15. * Constructs the default page cache request policy.
  16. *
  17. * @param \Drupal\Core\Session\SessionConfigurationInterface $session_configuration
  18. * The session configuration.
  19. */
  20. public function __construct(SessionConfigurationInterface $session_configuration) {
  21. $this->addPolicy(new CommandLineOrUnsafeMethod());
  22. $this->addPolicy(new NoSessionOpen($session_configuration));
  23. }
  24. }