本文整理匯總了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();
}
示例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();
}
示例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);
}
}
示例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
}
示例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
}