当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity\EntityAccessControlHandler类代码示例

本文整理汇总了PHP中Drupal\Core\Entity\EntityAccessControlHandler的典型用法代码示例。如果您正苦于以下问题:PHP EntityAccessControlHandler类的具体用法?PHP EntityAccessControlHandler怎么用?PHP EntityAccessControlHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EntityAccessControlHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     if ($operation === 'view') {
         return AccessResult::allowedIfHasPermission($account, 'access content');
     }
     return parent::checkAccess($entity, $operation, $account);
 }
开发者ID:oddhill,项目名称:entity_layout,代码行数:10,代码来源:EntityLayoutAccess.php

示例2: checkFieldAccess

 /**
  * {@inheritdoc}
  */
 protected function checkFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL)
 {
     if ($operation == 'edit') {
         return AccessResult::allowedIfHasPermissions($account, ['administer tmgmt', 'administer translation tasks']);
     }
     return parent::checkFieldAccess($operation, $field_definition, $account, $items);
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:10,代码来源:LocalTaskAccessControlHandler.php

示例3: __construct

  public function __construct(EntityTypeInterface $entity_type, FillPdfAccessHelperInterface $access_helper, FillPdfLinkManipulatorInterface $link_manipulator, FillPdfContextManagerInterface $context_manager) {
    parent::__construct($entity_type);

    $this->accessHelper = $access_helper;
    $this->linkManipulator = $link_manipulator;
    $this->contextManager = $context_manager;
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:7,代码来源:FillPdfFileContextAccessControlHandler.php

示例4: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     /** @var \Drupal\crm_core_contact\Entity\ContactType $entity */
     // First check permission.
     if (parent::checkAccess($entity, $operation, $account)->isForbidden()) {
         return AccessResult::forbidden();
     }
     switch ($operation) {
         case 'enable':
             // Only disabled contact type can be enabled.
             return AccessResult::allowedIf(!$entity->status());
         case 'disable':
             return AccessResult::allowedIf($entity->status());
         case 'delete':
             // If contact instance of this contact type exist, you can't delete it.
             $results = \Drupal::entityQuery('crm_core_contact')->condition('type', $entity->id())->execute();
             return AccessResult::allowedIf(empty($results));
             // @todo Which is it?
         // @todo Which is it?
         case 'edit':
         case 'update':
             // If the contact type is locked, you can't edit it.
             return AccessResult::allowed();
     }
 }
开发者ID:jasonruyle,项目名称:crm_core,代码行数:28,代码来源:ContactTypeAccessControlHandler.php

示例5: checkAccess

 /**
  * {@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') {
         if ($filter_format->isFallbackFormat()) {
             return AccessResult::allowed();
         } else {
             return AccessResult::allowedIfHasPermission($account, $filter_format->getPermissionName());
         }
     }
     // The fallback format may not be disabled.
     if ($operation == 'disable' && $filter_format->isFallbackFormat()) {
         return AccessResult::forbidden();
     }
     // 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 AccessResult::forbidden();
     }
     if (in_array($operation, array('disable', 'update'))) {
         return parent::checkAccess($filter_format, $operation, $langcode, $account);
     }
     // No opinion.
     return AccessResult::neutral();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:29,代码来源:FilterFormatAccessControlHandler.php

示例6: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     if ($operation === 'view') {
         return AccessResult::allowed();
     }
     return parent::checkAccess($entity, $operation, $account);
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:10,代码来源:BlockContentAccessControlHandler.php

示例7: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     /** @var \Drupal\crm_core_match\Matcher\MatcherConfigInterface $entity */
     return parent::checkAccess($entity, $operation, $account);
     // Deny delete access.
     // ->andIf(AccessResult::allowedIf($operation != 'delete'));
 }
开发者ID:jasonruyle,项目名称:crm_core,代码行数:10,代码来源:MatcherAccessControlHandler.php

示例8: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     $access = parent::checkAccess($entity, $operation, $account);
     if ($operation === 'view') {
         $access = $access->orIf(AccessResult::allowedIfHasPermission($account, 'access ' . $entity->getEntityTypeId()));
     }
     return $access;
 }
开发者ID:heddn,项目名称:content_entity_base,代码行数:11,代码来源:EntityBaseAccessControlHandler.php

示例9: checkAccess

 /**
  * Performs access checks.
  *
  * Uses permissions from host entity.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for which to check 'create' access.
  * @param string $operation
  *   The entity operation. Usually one of 'view', 'update', 'create' or
  *   'delete'.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The user for which to check access.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     $result = parent::checkAccess($entity, $operation, $account);
     if ($result->isForbidden()) {
         return $result;
     }
     return $entity->getHost()->access($operation, $account, TRUE);
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:24,代码来源:FieldCollectionItemAccessControlHandler.php

示例10: checkAccess

 /**
  * {@inheritdoc}
  */
 public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
 {
     if ($operation == 'view') {
         return AccessResult::allowed();
     } else {
         return parent::checkAccess($entity, $operation, $langcode, $account);
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:ViewAccessControlHandler.php

示例11: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     /** @var \Drupal\block\BlockInterface $entity */
     if ($operation != 'view') {
         return parent::checkAccess($entity, $operation, $account);
     }
     // Don't grant access to disabled blocks.
     if (!$entity->status()) {
         return AccessResult::forbidden()->addCacheableDependency($entity);
     } else {
         $conditions = [];
         $missing_context = FALSE;
         foreach ($entity->getVisibilityConditions() as $condition_id => $condition) {
             if ($condition instanceof ContextAwarePluginInterface) {
                 try {
                     $contexts = $this->contextRepository->getRuntimeContexts(array_values($condition->getContextMapping()));
                     $this->contextHandler->applyContextMapping($condition, $contexts);
                 } catch (ContextException $e) {
                     $missing_context = TRUE;
                 }
             }
             $conditions[$condition_id] = $condition;
         }
         if ($missing_context) {
             // If any context is missing then we might be missing cacheable
             // metadata, and don't know based on what conditions the block is
             // accessible or not. For example, blocks that have a node type
             // condition will have a missing context on any non-node route like the
             // frontpage.
             // @todo Avoid setting max-age 0 for some or all cases, for example by
             //   treating available contexts without value differently in
             //   https://www.drupal.org/node/2521956.
             $access = AccessResult::forbidden()->setCacheMaxAge(0);
         } elseif ($this->resolveConditions($conditions, 'and') !== FALSE) {
             // Delegate to the plugin.
             $block_plugin = $entity->getPlugin();
             try {
                 if ($block_plugin instanceof ContextAwarePluginInterface) {
                     $contexts = $this->contextRepository->getRuntimeContexts(array_values($block_plugin->getContextMapping()));
                     $this->contextHandler->applyContextMapping($block_plugin, $contexts);
                 }
                 $access = $block_plugin->access($account, TRUE);
             } catch (ContextException $e) {
                 // Setting access to forbidden if any context is missing for the same
                 // reasons as with conditions (described in the comment above).
                 // @todo Avoid setting max-age 0 for some or all cases, for example by
                 //   treating available contexts without value differently in
                 //   https://www.drupal.org/node/2521956.
                 $access = AccessResult::forbidden()->setCacheMaxAge(0);
             }
         } else {
             $access = AccessResult::forbidden();
         }
         $this->mergeCacheabilityFromConditions($access, $conditions);
         // Ensure that access is evaluated again when the block changes.
         return $access->addCacheableDependency($entity);
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:61,代码来源:BlockAccessControlHandler.php

示例12: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     $admin_access = parent::checkAccess($entity, $operation, $account);
     // Allow view with other permission.
     if ($operation === 'view') {
         return AccessResult::allowedIfHasPermission($account, 'view moderation states')->orIf($admin_access);
     }
     return $admin_access;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:12,代码来源:ModerationStateAccessControlHandler.php

示例13: checkFieldAccess

 /**
  * {@inheritdoc}
  */
 protected function checkFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL)
 {
     // No user can edit the status of a file. Prevents saving a new file as
     // persistent before even validating it.
     if ($field_definition->getName() === 'status' && $operation === 'edit') {
         return AccessResult::forbidden();
     }
     return parent::checkFieldAccess($operation, $field_definition, $account, $items);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:12,代码来源:FileAccessControlHandler.php

示例14: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     // ZZ is the fallback address format and it must always be present.
     if ($operation == 'delete' && $entity->id() == 'ZZ') {
         return AccessResult::forbidden();
     } else {
         return parent::checkAccess($entity, $operation, $account);
     }
 }
开发者ID:r-daneelolivaw,项目名称:chalk,代码行数:12,代码来源:AddressFormatAccessControlHandler.php

示例15: createAccess

 /**
  * {@inheritdoc}
  */
 public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE)
 {
     $account = $this->prepareUser($account);
     if ($account->hasPermission('bypass profile access')) {
         $result = AccessResult::allowed()->cachePerPermissions();
         return $return_as_object ? $result : $result->isAllowed();
     }
     $result = parent::createAccess($entity_bundle, $account, $context, TRUE)->cachePerPermissions();
     return $return_as_object ? $result : $result->isAllowed();
 }
开发者ID:augustpascual-mse,项目名称:job-searching-network,代码行数:13,代码来源:ProfileAccessControlHandler.php


注:本文中的Drupal\Core\Entity\EntityAccessControlHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。