Skip to content
Snippets Groups Projects
Unverified Commit 4a85296a authored by Alex Pott's avatar Alex Pott
Browse files

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
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment