user->id() == 1) { return 'is-super-user'; } if ($role === NULL) { return implode(',', $this->user->getRoles()); } else { return (in_array($role, $this->user->getRoles()) ? '0' : '1'); } } /** * {@inheritdoc} */ public function getCacheableMetadata($role = NULL) { return (new CacheableMetadata())->setCacheTags(['user:' . $this->user->id()]); } }