UserCacheContext.php 592 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Drupal\Core\Cache\Context;
  3. use Drupal\Core\Cache\CacheableMetadata;
  4. /**
  5. * Defines the UserCacheContext service, for "per user" caching.
  6. *
  7. * Cache context ID: 'user'.
  8. */
  9. class UserCacheContext extends UserCacheContextBase implements CacheContextInterface {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static function getLabel() {
  14. return t('User');
  15. }
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function getContext() {
  20. return $this->user->id();
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function getCacheableMetadata() {
  26. return new CacheableMetadata();
  27. }
  28. }