當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。