/**
  * {@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);
 }
Ejemplo n.º 5
0
 /**
  * {@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);
     }
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array())
 {
     $account = $this->prepareUser($account);
     if ($account->hasPermission('bypass node access')) {
         return TRUE;
     }
     if (!$account->hasPermission('access content')) {
         return FALSE;
     }
     return parent::createAccess($entity_bundle, $account, $context);
 }
 /**
  * {@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);
 }
Ejemplo n.º 8
0
 /**
  * {@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);
 }
Ejemplo n.º 10
0
 /**
  * {@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);
     }
 }
 /**
  * Creates a new MenuLinkContentAccessController.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type definition.
  * @param \Drupal\Core\Access\AccessManagerInterface $access_manager
  *   The access manager to check routes by name.
  */
 public function __construct(EntityTypeInterface $entity_type, AccessManagerInterface $access_manager)
 {
     parent::__construct($entity_type);
     $this->accessManager = $access_manager;
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
 {
     return $operation == 'view' || parent::checkAccess($entity, $operation, $langcode, $account);
 }
 /**
  * Constructs a ShortcutAccessController object.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type definition.
  * @param \Drupal\shortcut\ShortcutSetStorageInterface $shortcut_set_storage
  *   The shortcut_set storage.
  */
 public function __construct(EntityTypeInterface $entity_type, ShortcutSetStorageInterface $shortcut_set_storage)
 {
     parent::__construct($entity_type);
     $this->shortcutSetStorage = $shortcut_set_storage;
 }