本文整理汇总了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
}