Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
37
core/modules/user/src/RoleAccessControlHandler.php
Normal file
37
core/modules/user/src/RoleAccessControlHandler.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\user\RoleAccessControlHandler.
|
||||
*/
|
||||
|
||||
namespace Drupal\user;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Entity\EntityAccessControlHandler;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
/**
|
||||
* Defines the access control handler for the user role entity type.
|
||||
*
|
||||
* @see \Drupal\user\Entity\Role
|
||||
*/
|
||||
class RoleAccessControlHandler extends EntityAccessControlHandler {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
switch ($operation) {
|
||||
case 'delete':
|
||||
if ($entity->id() == RoleInterface::ANONYMOUS_ID || $entity->id() == RoleInterface::AUTHENTICATED_ID) {
|
||||
return AccessResult::forbidden();
|
||||
}
|
||||
|
||||
default:
|
||||
return parent::checkAccess($entity, $operation, $langcode, $account);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue