You are here

function smart_date_entity_access in Smart Date 3.0.x

Same name and namespace in other branches
  1. 8.2 smart_date.module \smart_date_entity_access()
  2. 8 smart_date.module \smart_date_entity_access()
  3. 3.x smart_date.module \smart_date_entity_access()
  4. 3.1.x smart_date.module \smart_date_entity_access()
  5. 3.2.x smart_date.module \smart_date_entity_access()
  6. 3.3.x smart_date.module \smart_date_entity_access()
  7. 3.4.x smart_date.module \smart_date_entity_access()

Implements hook_entity_access().

Prevent deletion of the default configuration.

File

./smart_date.module, line 49
Field hooks for a field that stores a start and end date as timestamps.

Code

function smart_date_entity_access($entity, $operation, $account) {
  $info = $entity
    ->getEntityType();
  if ($info
    ->id() == 'smart_date_format') {
    if ($entity
      ->id() == 'default' && $operation == 'delete') {
      return AccessResult::forbidden();
    }
    else {
      return AccessResult::neutral();
    }
  }
}