Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ProfileAccessControlHandler | |
100.00% |
6 / 6 |
|
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| checkAccess | |
100.00% |
6 / 6 |
|
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\display_builder; |
| 6 | |
| 7 | use Drupal\Core\Access\AccessResult; |
| 8 | use Drupal\Core\Access\AccessResultInterface; |
| 9 | use Drupal\Core\Entity\EntityAccessControlHandler; |
| 10 | use Drupal\Core\Entity\EntityInterface; |
| 11 | use Drupal\Core\Session\AccountInterface; |
| 12 | |
| 13 | /** |
| 14 | * Defines the access control handler for the instance entity type. |
| 15 | */ |
| 16 | final class ProfileAccessControlHandler extends EntityAccessControlHandler { |
| 17 | |
| 18 | /** |
| 19 | * {@inheritdoc} |
| 20 | */ |
| 21 | protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account): AccessResultInterface { |
| 22 | /** @var \Drupal\display_builder\Entity\Profile $entity */ |
| 23 | $access = parent::checkAccess($entity, $operation, $account); |
| 24 | |
| 25 | if ($access->isAllowed()) { |
| 26 | // Permission to administer profiles gives permission to use all profiles. |
| 27 | return $access; |
| 28 | } |
| 29 | |
| 30 | if ($operation === 'view') { |
| 31 | return AccessResult::allowedIfHasPermission($account, $entity->getPermissionName()); |
| 32 | } |
| 33 | |
| 34 | return AccessResult::forbidden(); |
| 35 | } |
| 36 | |
| 37 | } |
Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not
necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once.
Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 21 | protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account): AccessResultInterface { |
| 22 | /** @var \Drupal\display_builder\Entity\Profile $entity */ |
| 23 | $access = parent::checkAccess($entity, $operation, $account); |
| 24 | |
| 25 | if ($access->isAllowed()) { |
| 27 | return $access; |
| 30 | if ($operation === 'view') { |
| 31 | return AccessResult::allowedIfHasPermission($account, $entity->getPermissionName()); |
| 34 | return AccessResult::forbidden(); |