Skip to content
Snippets Groups Projects

Issue #3376846: Implement the new access policy API

Compare and
16 files
+ 802
403
Compare changes
  • Side-by-side
  • Inline
Files
16
@@ -2,7 +2,6 @@
namespace Drupal\Core\Cache\Context;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\PermissionsHashGeneratorInterface;
@@ -51,17 +50,7 @@ public function getContext() {
* {@inheritdoc}
*/
public function getCacheableMetadata() {
$cacheable_metadata = new CacheableMetadata();
// The permissions hash changes when:
// - a user is updated to have different roles;
$tags = ['user:' . $this->user->id()];
// - a role is updated to have different permissions.
foreach ($this->user->getRoles() as $rid) {
$tags[] = "config:user.role.$rid";
}
return $cacheable_metadata->setCacheTags($tags);
return $this->permissionsHashGenerator->getCacheableMetadata($this->user);
}
}
Loading