PageCacheRequestPolicy.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Drupal\domain_config_hook_test\PageCache\RequestPolicy;
  3. use Drupal\Core\Config\ConfigFactory;
  4. use Drupal\Core\PageCache\RequestPolicyInterface;
  5. use Drupal\Core\Session\SessionConfigurationInterface;
  6. use Symfony\Component\HttpFoundation\Request;
  7. /**
  8. * A page cache request policy.
  9. *
  10. * This service is not meant to DO anything, it's just meant to represent
  11. * a service that might be present in the Drupal community. For example,
  12. * persistent_login module has this same structure.
  13. */
  14. class PageCacheRequestPolicy implements RequestPolicyInterface {
  15. /**
  16. * Drupal config factory.
  17. *
  18. * @var \Drupal\Core\Config\ConfigFactory
  19. */
  20. protected $configFactory;
  21. /**
  22. * Constructor.
  23. *
  24. * @param \Drupal\Core\Config\ConfigFactory $config_factory
  25. * Drupal config factory.
  26. */
  27. public function __construct(ConfigFactory $config_factory) {
  28. $this->configFactory = $config_factory;
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function check(Request $request) {
  34. // This line is important. You have to use this service for it to fail.
  35. $this->configFactory
  36. ->get('system.site');
  37. return NULL;
  38. }
  39. }