roleDelegationAccessCheck = $roleDelegationAccessCheck; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, $plugin_definition, $container->get('entity_type.manager')->getDefinition('user_role'), $container->get('access_check.role_delegation') ); } /** * {@inheritdoc} */ public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { $access = parent::access($object, $account, $return_as_object); // If access == true, the user already has the administer users permission. if ($access === TRUE) { return $access; } // Check if the user has access to add the role to the user. return $this->roleDelegationAccessCheck->access($account); } }