Unverified Commit 4a85296a authored by alexpott's avatar alexpott

Issue #2952544 by hexblot, Sam152, timmillwood: Provide a reason for...

Issue #2952544 by hexblot, Sam152, timmillwood: Provide a reason for AccessResult::forbidden() in latest revision
parent d32d0c53
......@@ -196,7 +196,7 @@ function content_moderation_entity_access(EntityInterface $entity, $operation, A
$transition_validation = \Drupal::service('content_moderation.state_transition_validation');
$valid_transition_targets = $transition_validation->getValidTransitions($entity, $account);
$access_result = $valid_transition_targets ? AccessResult::neutral() : AccessResult::forbidden();
$access_result = $valid_transition_targets ? AccessResult::neutral() : AccessResult::forbidden('No valid transitions exist for given account.');
$access_result->addCacheableDependency($entity);
$access_result->addCacheableDependency($account);
......@@ -224,7 +224,7 @@ function content_moderation_entity_field_access($operation, FieldDefinitionInter
// Deny edit access to the published field if the entity is being moderated.
if ($entity_type->hasKey('published') && $moderation_info->isModeratedEntity($entity) && $entity->moderation_state && $field_definition->getName() == $entity_type->getKey('published')) {
return AccessResult::forbidden();
return AccessResult::forbidden('Cannot edit the published field of moderated entities.');
}
}
......
......@@ -68,7 +68,7 @@ public function access(Route $route, RouteMatchInterface $route_match, AccountIn
return $access_result->addCacheableDependency($entity);
}
return AccessResult::forbidden()->addCacheableDependency($entity);
return AccessResult::forbidden('No pending revision for moderated entity.')->addCacheableDependency($entity);
}
/**
......
......@@ -75,7 +75,7 @@ public function access($entity, AccountInterface $account = NULL, $return_as_obj
$bundle_info = $this->bundleInfo->getBundleInfo($entity->getEntityTypeId());
$bundle_label = $bundle_info[$entity->bundle()]['label'];
drupal_set_message($this->t("@bundle @label were skipped as they are under moderation and may not be directly published.", ['@bundle' => $bundle_label, '@label' => $entity->getEntityType()->getPluralLabel()]), 'warning');
$result = AccessResult::forbidden();
$result = AccessResult::forbidden('Cannot directly publish moderated entities.');
return $return_as_object ? $result : $result->isAllowed();
}
return parent::access($entity, $account, $return_as_object);
......
......@@ -75,7 +75,7 @@ public function access($entity, AccountInterface $account = NULL, $return_as_obj
$bundle_info = $this->bundleInfo->getBundleInfo($entity->getEntityTypeId());
$bundle_label = $bundle_info[$entity->bundle()]['label'];
drupal_set_message($this->t("@bundle @label were skipped as they are under moderation and may not be directly unpublished.", ['@bundle' => $bundle_label, '@label' => $entity->getEntityType()->getPluralLabel()]), 'warning');
$result = AccessResult::forbidden();
$result = AccessResult::forbidden('Cannot directly unpublish moderated entities.');
return $return_as_object ? $result : $result->isAllowed();
}
return parent::access($entity, $account, $return_as_object);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment