Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ContactDetailTypeAccessControlHandler | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
| checkAccess | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Drupal\crm; |
| 4 | |
| 5 | use Drupal\Core\Access\AccessResult; |
| 6 | use Drupal\Core\Entity\EntityAccessControlHandler; |
| 7 | use Drupal\Core\Entity\EntityInterface; |
| 8 | use Drupal\Core\Session\AccountInterface; |
| 9 | |
| 10 | /** |
| 11 | * Defines the access control handler for the Contact Detail Type entity type. |
| 12 | * |
| 13 | * @see \Drupal\crm\Entity\ContactDetailType |
| 14 | */ |
| 15 | class ContactDetailTypeAccessControlHandler extends EntityAccessControlHandler { |
| 16 | |
| 17 | /** |
| 18 | * {@inheritdoc} |
| 19 | */ |
| 20 | protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { |
| 21 | switch ($operation) { |
| 22 | case 'view': |
| 23 | return AccessResult::allowedIfHasPermission($account, 'access content'); |
| 24 | |
| 25 | case 'delete': |
| 26 | if ($entity->isLocked()) { |
| 27 | return AccessResult::forbidden()->addCacheableDependency($entity); |
| 28 | } |
| 29 | else { |
| 30 | return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity); |
| 31 | } |
| 32 | |
| 33 | default: |
| 34 | return parent::checkAccess($entity, $operation, $account); |
| 35 | |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | } |