Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Cache / Context / IsSuperUserCacheContext.php
1 <?php
2
3 namespace Drupal\Core\Cache\Context;
4
5 use Drupal\Core\Cache\CacheableMetadata;
6
7 /**
8  * Defines the IsSuperUserCacheContext service, for "super user or not" caching.
9  *
10  * Cache context ID: 'user.is_super_user'.
11  */
12 class IsSuperUserCacheContext extends UserCacheContextBase implements CacheContextInterface {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static function getLabel() {
18     return t('Is super user');
19   }
20
21   /**
22    * {@inheritdoc}
23    */
24   public function getContext() {
25     return ((int) $this->user->id()) === 1 ? '1' : '0';
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function getCacheableMetadata() {
32     return new CacheableMetadata();
33   }
34
35 }