function Role::calculateDependencies
Same name in this branch
- 10 core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::calculateDependencies()
Same name in other branches
- 9 core/modules/user/src/Entity/Role.php \Drupal\user\Entity\Role::calculateDependencies()
- 9 core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::calculateDependencies()
- 8.9.x core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::calculateDependencies()
- 11.x core/modules/user/src/Entity/Role.php \Drupal\user\Entity\Role::calculateDependencies()
- 11.x core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::calculateDependencies()
Overrides ConfigEntityBase::calculateDependencies
File
-
core/
modules/ user/ src/ Entity/ Role.php, line 203
Class
- Role
- Defines the user role entity class.
Namespace
Drupal\user\EntityCode
public function calculateDependencies() {
parent::calculateDependencies();
// Load all permission definitions.
$permission_definitions = \Drupal::service('user.permissions')->getPermissions();
$valid_permissions = array_intersect($this->permissions, array_keys($permission_definitions));
$invalid_permissions = array_diff($this->permissions, $valid_permissions);
if (!empty($invalid_permissions)) {
throw new \RuntimeException('Adding non-existent permissions to a role is not allowed. The incorrect permissions are "' . implode('", "', $invalid_permissions) . '".');
}
foreach ($valid_permissions as $permission) {
// Depend on the module that is providing this permissions.
$this->addDependency('module', $permission_definitions[$permission]['provider']);
// Depend on any other dependencies defined by permissions granted to
// this role.
if (!empty($permission_definitions[$permission]['dependencies'])) {
$this->addDependencies($permission_definitions[$permission]['dependencies']);
}
}
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.