FieldStorageConfigAccess.php in Field tools 8
Namespace
Drupal\field_tools\EntityHandlerFile
src/EntityHandler/FieldStorageConfigAccess.phpView source
<?php
namespace Drupal\field_tools\EntityHandler;
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 storage entity type.
*
* This just handles the 'delete' operation for our form.
*
* @see Drupal\field_tools\Form\FieldStorageConfigDeleteForm
*/
class FieldStorageConfigAccess extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation == 'delete') {
if ($entity
->isLocked()) {
return AccessResult::forbidden()
->addCacheableDependency($entity);
}
else {
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity
->getTargetEntityTypeId() . ' fields')
->addCacheableDependency($entity);
}
}
return AccessResult::allowedIfHasPermission($account, 'administer ' . $entity
->getTargetEntityTypeId() . ' fields');
}
}
Classes
Name | Description |
---|---|
FieldStorageConfigAccess | Defines the access control handler for the field storage entity type. |