/** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { if ($operation == 'delete' && $entity->isLocked()) { return FALSE; } return parent::checkAccess($entity, $operation, $langcode, $account); }
/** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { if ($operation === 'view') { return TRUE; } return parent::checkAccess($entity, $operation, $langcode, $account); }
/** * {@inheritdoc} */ public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { switch ($operation) { case 'update': case 'delete': return !$entity->locked && parent::checkAccess($entity, $operation, $langcode, $account); break; } return FALSE; }
/** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { // There are no restrictions on viewing a date format. if ($operation == 'view') { return TRUE; } elseif (in_array($operation, array('update', 'delete')) && $entity->isLocked()) { return FALSE; } return parent::checkAccess($entity, $operation, $langcode, $account); }
/** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { switch ($operation) { case 'delete': if ($entity->id() == DRUPAL_ANONYMOUS_RID || $entity->id() == DRUPAL_AUTHENTICATED_RID) { return FALSE; } default: return parent::checkAccess($entity, $operation, $langcode, $account); } }
/** * {@inheritdoc} */ public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { if ($operation == 'view') { // Do not allow access personal category via site-wide route. return $account->hasPermission('access site-wide contact form') && $entity->id() !== 'personal'; } elseif ($operation == 'delete' || $operation == 'update') { // Do not allow the 'personal' category to be deleted, as it's used for // the personal contact form. return $account->hasPermission('administer contact forms') && $entity->id() !== 'personal'; } return parent::checkAccess($entity, $operation, $langcode, $account); }
/** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { /** @var $entity \Drupal\block\BlockInterface */ if ($operation != 'view') { return parent::checkAccess($entity, $operation, $langcode, $account); } // Deny access to disabled blocks. if (!$entity->status()) { return FALSE; } // Delegate to the plugin. return $entity->getPlugin()->access($account); }
/** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { /** @var $entity \Drupal\search\SearchPageInterface */ if (in_array($operation, array('delete', 'disable')) && $entity->isDefaultSearch()) { return FALSE; } if ($operation == 'view') { if (!$entity->status()) { return FALSE; } $plugin = $entity->getPlugin(); if ($plugin instanceof AccessibleInterface) { return $plugin->access($operation, $account); } return TRUE; } return parent::checkAccess($entity, $operation, $langcode, $account); }
/** * {@inheritdoc} */ protected function checkAccess(EntityInterface $filter_format, $operation, $langcode, AccountInterface $account) { /** @var \Drupal\filter\FilterFormatInterface $filter_format */ // All users are allowed to use the fallback filter. if ($operation == 'use') { return $filter_format->isFallbackFormat() || $account->hasPermission($filter_format->getPermissionName()); } // The fallback format may not be disabled. if ($operation == 'disable' && $filter_format->isFallbackFormat()) { return FALSE; } // We do not allow filter formats to be deleted through the UI, because that // would render any content that uses them unusable. if ($operation == 'delete') { return FALSE; } if (in_array($operation, array('disable', 'update'))) { return parent::checkAccess($filter_format, $operation, $langcode, $account); } }
/** * {@inheritdoc} */ public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { return $operation == 'view' || parent::checkAccess($entity, $operation, $langcode, $account); }