Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CrmCaseAccessControlHandler | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
checkAccess | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
30 | |||
checkCreateAccess | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Drupal\crm_case; |
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 crm case entity type. |
12 | */ |
13 | class CrmCaseAccessControlHandler extends EntityAccessControlHandler { |
14 | |
15 | /** |
16 | * {@inheritdoc} |
17 | */ |
18 | protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { |
19 | |
20 | switch ($operation) { |
21 | case 'view': |
22 | return AccessResult::allowedIfHasPermission($account, 'view crm case'); |
23 | |
24 | case 'update': |
25 | return AccessResult::allowedIfHasPermissions( |
26 | $account, |
27 | ['edit crm case', 'administer crm case'], |
28 | 'OR', |
29 | ); |
30 | |
31 | case 'delete': |
32 | return AccessResult::allowedIfHasPermissions( |
33 | $account, |
34 | ['delete crm case', 'administer crm case'], |
35 | 'OR', |
36 | ); |
37 | |
38 | default: |
39 | // No opinion. |
40 | return AccessResult::neutral(); |
41 | } |
42 | |
43 | } |
44 | |
45 | /** |
46 | * {@inheritdoc} |
47 | */ |
48 | protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { |
49 | return AccessResult::allowedIfHasPermissions( |
50 | $account, |
51 | ['create crm case', 'administer crm case'], |
52 | 'OR', |
53 | ); |
54 | } |
55 | |
56 | } |