Mercurial > hg > isophonics-drupal-site
view core/modules/block_content/src/BlockContentAccessControlHandler.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
line wrap: on
line source
<?php namespace Drupal\block_content; use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Session\AccountInterface; /** * Defines the access control handler for the custom block entity type. * * @see \Drupal\block_content\Entity\BlockContent */ class BlockContentAccessControlHandler extends EntityAccessControlHandler { /** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { return AccessResult::allowedIf($entity->isPublished())->addCacheableDependency($entity) ->orIf(AccessResult::allowedIfHasPermission($account, 'administer blocks')); } return parent::checkAccess($entity, $operation, $account); } }