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
38
core/modules/field/src/FieldConfigAccessControlHandler.php
Normal file
38
core/modules/field/src/FieldConfigAccessControlHandler.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\field\FieldConfigAccessControlHandler.
|
||||
*/
|
||||
|
||||
namespace Drupal\field;
|
||||
|
||||
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 field entity type.
|
||||
*
|
||||
* @see \Drupal\field\Entity\FieldConfig
|
||||
*/
|
||||
class FieldConfigAccessControlHandler extends EntityAccessControlHandler {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
if ($operation == 'delete') {
|
||||
$field_storage_entity = $entity->getFieldStorageDefinition();
|
||||
if ($field_storage_entity->isLocked()) {
|
||||
return AccessResult::forbidden()->cacheUntilEntityChanges($field_storage_entity);
|
||||
}
|
||||
else {
|
||||
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' fields')->cacheUntilEntityChanges($field_storage_entity);
|
||||
}
|
||||
}
|
||||
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' fields');
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue