| Conditions | 8 |
| Paths | 9 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 9.8645 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | 2 | public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null) |
|
| 27 | { |
||
| 28 | 2 | if ($resource === null) { |
|
| 29 | return false; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** @var AbstractModel $object */ |
||
| 33 | 2 | $object = $resource->getInstance(); |
|
| 34 | |||
| 35 | 2 | $currentFamilyOwner = User::getCurrent(); |
|
| 36 | 2 | if ($currentFamilyOwner && $currentFamilyOwner->getOwner()) { |
|
| 37 | $currentFamilyOwner = $currentFamilyOwner->getOwner(); |
||
| 38 | } |
||
| 39 | |||
| 40 | 2 | $objectFamilyOwner = $object->getOwner(); |
|
| 41 | 2 | if ($objectFamilyOwner && $objectFamilyOwner->getOwner()) { |
|
| 42 | $objectFamilyOwner = $objectFamilyOwner->getOwner(); |
||
| 43 | } |
||
| 44 | |||
| 45 | 2 | if ($currentFamilyOwner && $currentFamilyOwner === $objectFamilyOwner) { |
|
| 46 | 2 | return true; |
|
| 47 | } |
||
| 48 | |||
| 49 | return $acl->reject('the object does not belong to the family'); |
||
| 50 | } |
||
| 52 |