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


PHP EntityAccessControlHandler::access方法代码示例

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


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

示例1: access

 /**
  * {@inheritdoc}
  */
 public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL, $return_as_object = FALSE)
 {
     $account = $this->prepareUser($account);
     if ($account->hasPermission('bypass node access')) {
         $result = AccessResult::allowed()->cachePerPermissions();
         return $return_as_object ? $result : $result->isAllowed();
     }
     if (!$account->hasPermission('access content')) {
         $result = AccessResult::forbidden()->cachePerPermissions();
         return $return_as_object ? $result : $result->isAllowed();
     }
     $result = parent::access($entity, $operation, $account, TRUE)->cachePerPermissions();
     return $return_as_object ? $result : $result->isAllowed();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:17,代码来源:NodeAccessControlHandler.php

示例2: access

 /**
  * {@inheritdoc}
  */
 public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL, $return_as_object = FALSE)
 {
     $result = AccessResult::neutral();
     $account = $this->prepareUser($account);
     // $account = workflow_current_user($account);
     /* @var $transition WorkflowTransitionInterface */
     $transition = $entity;
     // This is only for Edit/Delete transition. For Add/create, use createAccess.
     switch ($entity->getEntityTypeId()) {
         case 'workflow_transition':
         case 'workflow_scheduled_transition':
             switch ($operation) {
                 case 'update':
                     $is_owner = WorkflowManager::isOwner($account, $transition);
                     $type_id = $transition->getWorkflowId();
                     if ($account->hasPermission("bypass {$type_id} workflow_transition access")) {
                         $result = AccessResult::allowed()->cachePerPermissions();
                     } elseif ($account->hasPermission("edit any {$type_id} workflow_transition")) {
                         $result = AccessResult::allowed()->cachePerPermissions();
                     } elseif ($is_owner && $account->hasPermission("edit own {$type_id} workflow_transition")) {
                         $result = AccessResult::allowed()->cachePerPermissions();
                     }
                     return $return_as_object ? $result : $result->isAllowed();
                     break;
                 case 'delete':
                     // The delete operation is not defined for Transitions.
                     $result = AccessResult::forbidden();
                     break;
                 case 'revert':
                     // @see workflow_operations.
                 // @see workflow_operations.
                 default:
                     $type_id = $transition->getWorkflowId();
                     $result = parent::access($entity, $account, $return_as_object);
                     //if ($account->hasPermission("bypass $type_id workflow_transition access")) {
                     //  $result = AccessResult::allowed()->cachePerPermissions();
                     //}
                     break;
             }
             // End of switch ($operation).
             break;
         case 'workflow_config_transition':
             workflow_debug(__FILE__, __FUNCTION__, __LINE__, $account->id(), $transition->getOwnerId());
             // @todo D8-port: still test this snippet.
             break;
     }
     $result = parent::access($entity, $operation, $account, TRUE)->cachePerPermissions();
     return $return_as_object ? $result : $result->isAllowed();
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:52,代码来源:WorkflowAccessControlHandler.php

示例3: access

 /**
  * {@inheritdoc}
  */
 public function access(EntityInterface $entity, $operation, $langcode = LanguageInterface::LANGCODE_DEFAULT, AccountInterface $account = NULL, $return_as_object = FALSE) {
   /* @var $entity \Drupal\mailchimp_campaign\Entity\MailchimpCampaign */
   $status = $entity->mc_data['status'];
   switch ($operation) {
     case 'send':
     case 'edit':
     case 'delete':
       return ($status == MAILCHIMP_STATUS_SENT) ? AccessResult::forbidden() : AccessResult::allowed();
       break;
     case 'stats':
       return ($status == MAILCHIMP_STATUS_SENT) ? AccessResult::allowed() : AccessResult::forbidden();
     default:
       return parent::access($entity, $operation, $langcode, $account, $return_as_object);
   }
 }
开发者ID:kaperkin,项目名称:drupal_8_shelby_site,代码行数:18,代码来源:MailchimpCampaignAccessControlHandler.php

示例4: access

 public function access(EntityInterface $entity, $operation, $langcode = LanguageInterface::LANGCODE_DEFAULT, AccountInterface $account = NULL, $return_as_object = FALSE) {
   return parent::access($entity, $operation, $langcode, $account, $return_as_object); // TODO: Change the autogenerated stub
 }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:3,代码来源:EFormSubmissionAccessControlHandler.php

示例5: access

 public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL, $return_as_object = FALSE)
 {
     return parent::access($entity, $operation, $account, $return_as_object);
     // TODO: Change the autogenerated stub
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:5,代码来源:EFormSubmissionAccessControlHandler.php


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