EntityViewDisplayAccessControlHandler.php

Same filename in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Entity/Access/EntityViewDisplayAccessControlHandler.php
  2. 10 core/lib/Drupal/Core/Entity/Entity/Access/EntityViewDisplayAccessControlHandler.php
  3. 11.x core/lib/Drupal/Core/Entity/Entity/Access/EntityViewDisplayAccessControlHandler.php

Namespace

Drupal\Core\Entity\Entity\Access

File

core/lib/Drupal/Core/Entity/Entity/Access/EntityViewDisplayAccessControlHandler.php

View source
<?php

namespace Drupal\Core\Entity\Entity\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Provides an entity access control handler for displays.
 */
class EntityViewDisplayAccessControlHandler extends EntityAccessControlHandler {
    
    /**
     * {@inheritdoc}
     */
    protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
        
        /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $entity */
        return parent::checkAccess($entity, $operation, $account)->orIf(AccessResult::allowedIfHasPermission($account, 'administer ' . $entity->getTargetEntityTypeId() . ' display'));
    }

}

Classes

Title Deprecated Summary
EntityViewDisplayAccessControlHandler Provides an entity access control handler for displays.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.