function NodeAccessGrantsCacheContext::__construct

Same name and namespace in other branches
  1. 11.x core/modules/node/src/Cache/NodeAccessGrantsCacheContext.php \Drupal\node\Cache\NodeAccessGrantsCacheContext::__construct()

Constructs a new UserCacheContextBase class.

Parameters

\Drupal\Core\Session\AccountInterface $user: The current user.

Overrides UserCacheContextBase::__construct

File

core/modules/node/src/Cache/NodeAccessGrantsCacheContext.php, line 31

Class

NodeAccessGrantsCacheContext
Defines the node access view cache context service.

Namespace

Drupal\node\Cache

Code

public function __construct(AccountInterface $user, protected EntityTypeManagerInterface $entityTypeManager, ?NodeGrantsHelper $nodeGrantsHelper = NULL) {
  parent::__construct($user);
  if (!$nodeGrantsHelper) {
    @trigger_error('Calling NodeAccessGrantsCacheContext::__construct() without the $nodeGrantsHelper argument is deprecated in drupal:11.4.0 and the $nodeGrantsHelper argument will be required in drupal:12.0.0. See https://www.drupal.org/node/3578055', E_USER_DEPRECATED);
    $nodeGrantsHelper = \Drupal::service(NodeGrantsHelper::class);
  }
  $this->nodeGrantsHelper = $nodeGrantsHelper;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.