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


PHP AccessResult::allowedIfHasPermissions方法代码示例

本文整理汇总了PHP中Drupal\Core\Access\AccessResult::allowedIfHasPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP AccessResult::allowedIfHasPermissions方法的具体用法?PHP AccessResult::allowedIfHasPermissions怎么用?PHP AccessResult::allowedIfHasPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Access\AccessResult的用法示例。


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

示例1: defaultAccess

 /**
  * {@inheritdoc}
  */
 public function defaultAccess($operation = 'view', AccountInterface $account = NULL)
 {
     if ($operation == 'view') {
         return AccessResult::allowed();
     }
     return AccessResult::allowedIfHasPermissions($account, ['create url aliases', 'administer url aliases'], 'OR')->cachePerPermissions();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:PathFieldItemList.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: blockAccess

 /**
  * {@inheritdoc}
  */
 protected function blockAccess(AccountInterface $account)
 {
     if ($this->masquerade->isMasquerading()) {
         return AccessResult::forbidden()->addCacheContexts(['is_masquerading']);
     }
     // Display block for all users that has any of masquerade permissions.
     return AccessResult::allowedIfHasPermissions($account, $this->masquerade->getPermissions(), 'OR');
 }
开发者ID:nicolaspoulain,项目名称:bb8,代码行数:11,代码来源:MasqueradeBlock.php

示例4: access

 /**
  * Check to see if user has any permissions to masquerade.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *   Run access checks for this account.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(AccountInterface $account)
 {
     // Uid 1 may masquerade as anyone.
     if ($account->id() == 1) {
         return AccessResult::allowed()->cachePerUser();
     }
     $permissions = $this->masquerade->getPermissions();
     return AccessResult::allowedIfHasPermissions($account, $permissions, 'OR');
 }
开发者ID:nicolaspoulain,项目名称:bb8,代码行数:18,代码来源:SwitchAccessCheck.php

示例5: checkCreateAccess

  /**
   * {@inheritdoc}
   */
  protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
    $access_result = AccessResult::allowedIfHasPermissions($account, ["create {$entity_bundle} entityqueue", 'manipulate all entityqueues', 'administer entityqueue'], 'OR');

    if ($entity_bundle) {
      $queue = EntityQueue::load($entity_bundle);
      $access_result = AccessResult::allowedIf(!$queue->getHandlerPlugin()->hasAutomatedSubqueues());
    }

    return $access_result;
  }
开发者ID:jkyto,项目名称:agolf,代码行数:13,代码来源:EntitySubqueueAccessControlHandler.php

示例6: checkCreateAccess

 /**
  * {@inheritdoc}
  */
 protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL)
 {
     $contact_type_is_active = empty($entity_bundle);
     // Load the contact type entity.
     if (!empty($entity_bundle)) {
         /* @var \Drupal\crm_core_contact\Entity\ContactType $contact_type_entity */
         $contact_type_entity = ContactType::load($entity_bundle);
         $contact_type_is_active = $contact_type_entity->status();
     }
     return AccessResult::allowedIf($contact_type_is_active)->andIf(AccessResult::allowedIfHasPermissions($account, ['administer crm_core_contact entities', 'create crm_core_contact entities', 'create crm_core_contact entities of bundle ' . $entity_bundle], 'OR'));
 }
开发者ID:jasonruyle,项目名称:crm_core,代码行数:14,代码来源:ContactAccessControlHandler.php

示例7: access

 /**
  * Checks access.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, AccountInterface $account)
 {
     $permission = $route->getRequirement('_permission');
     // Allow to conjunct the permissions with OR ('+') or AND (',').
     $split = explode(',', $permission);
     if (count($split) > 1) {
         return AccessResult::allowedIfHasPermissions($account, $split, 'AND');
     } else {
         $split = explode('+', $permission);
         return AccessResult::allowedIfHasPermissions($account, $split, 'OR');
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:23,代码来源:PermissionAccessCheck.php

示例8: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     /** @var ScheduledUpdate $entity */
     if ($operation == 'view') {
         return AccessResult::allowedIfHasPermission($account, 'view scheduled update entities');
     }
     $type_id = $entity->bundle();
     if ($entity->getOwnerId() == $account->id()) {
         // If owner that needs either own or any permission, not both.
         return AccessResult::allowedIfHasPermissions($account, ["{$operation} any {$type_id} scheduled updates", "{$operation} own {$type_id} scheduled updates"], 'OR');
     } else {
         return AccessResult::allowedIfHasPermission($account, "{$operation} any {$type_id} scheduled updates");
     }
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:17,代码来源:ScheduledUpdateAccessControlHandler.php

示例9: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     switch ($operation) {
         case 'view':
             return AccessResult::allowedIfHasPermission($account, 'access content');
         case 'update':
             return AccessResult::allowedIfHasPermissions($account, ["edit terms in {$entity->bundle()}", 'administer taxonomy'], 'OR');
         case 'delete':
             return AccessResult::allowedIfHasPermissions($account, ["delete terms in {$entity->bundle()}", 'administer taxonomy'], 'OR');
         default:
             // No opinion.
             return AccessResult::neutral();
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:17,代码来源:TermAccessControlHandler.php

示例10: access

 /**
  * {@inheritdoc}
  */
 public function access(AccountInterface $account)
 {
     $domain = $this->domainNegotiator->getActiveDomain();
     // Is the domain allowed?
     // No domain, let it pass.
     if (empty($domain)) {
         return AccessResult::allowed()->setCacheMaxAge(0);
     }
     // Active domain, let it pass.
     if ($domain->status()) {
         return AccessResult::allowed()->setCacheMaxAge(0);
     } else {
         $permissions = array('administer domains', 'access inactive domains');
         $operator = 'OR';
         return AccessResult::allowedIfHasPermissions($account, $permissions, $operator)->setCacheMaxAge(0);
     }
 }
开发者ID:dropdog,项目名称:play,代码行数:20,代码来源:DomainAccessCheck.php

示例11: checkCreateAccess

 /**
  * {@inheritdoc}
  */
 protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL)
 {
     return AccessResult::allowedIfHasPermission($account, 'administer shortcuts')->orIf(AccessResult::allowedIfHasPermissions($account, ['access shortcuts', 'customize shortcut links'], 'AND'));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:7,代码来源:ShortcutSetAccessControlHandler.php

示例12: access

 /**
  * Custom access check for continuous job form.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *   Run access checks for this account.
  *
  * @return \Drupal\Core\Access\AccessResult
  *   Returns allowed if we have a translator with ContinuousSourceInterface
  *   and the logged in user has permission to create translation jobs.
  */
 public function access(AccountInterface $account)
 {
     if (\Drupal::service('tmgmt.continuous')->checkIfContinuousTranslatorAvailable()) {
         return AccessResult::allowedIfHasPermissions($account, ['administer tmgmt'])->addCacheTags(['config:tmgmt_translator_list']);
     }
     return AccessResult::forbidden()->addCacheTags(['config:tmgmt_translator_list']);
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:17,代码来源:ContinuousJobForm.php

示例13: checkCreateAccess

 /**
  * {@inheritdoc}
  */
 protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL)
 {
     return AccessResult::allowedIfHasPermissions($account, ['add any ' . $entity_bundle . ' profile', 'add own ' . $entity_bundle . ' profile'], 'OR');
 }
开发者ID:augustpascual-mse,项目名称:job-searching-network,代码行数:7,代码来源:ProfileAccessControlHandler.php

示例14: addPageAccess

 /**
  * Determine access to update add page.
  *
  * If user has permission to add any types they should have access to this page.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *
  * @return \Drupal\Core\Access\AccessResult
  */
 public function addPageAccess(AccountInterface $account)
 {
     $types = $this->typeStorage->loadMultiple();
     $perms = [];
     foreach ($types as $type_id => $type) {
         $perms[] = "create {$type_id} scheduled updates";
     }
     return AccessResult::allowedIfHasPermissions($account, $perms, 'OR');
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:18,代码来源:ScheduledUpdateAddController.php

示例15: testAllowedIfHasPermissions

 /**
  * Tests allowedIfHasPermissions().
  *
  * @covers ::allowedIfHasPermissions
  *
  * @dataProvider providerTestAllowedIfHasPermissions
  */
 public function testAllowedIfHasPermissions($permissions, $conjunction, $expected_access)
 {
     $account = $this->getMock('\\Drupal\\Core\\Session\\AccountInterface');
     $account->expects($this->any())->method('hasPermission')->willReturnMap([['allowed', TRUE], ['denied', FALSE]]);
     $access_result = AccessResult::allowedIfHasPermissions($account, $permissions, $conjunction);
     $this->assertEquals($expected_access, $access_result);
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:14,代码来源:AccessResultTest.php


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