summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-03-29 16:31:46 (GMT)
committerAlex Pott2018-03-29 16:31:46 (GMT)
commit4a85296adc550e438394a4db934a42a454ffed19 (patch)
tree2a341850d2da1bfa3fd181d652e848d273306a1e
parentd32d0c53b9c28d4c5239c3c39dd9aadd217a7d70 (diff)
Issue #2952544 by hexblot, Sam152, timmillwood: Provide a reason for AccessResult::forbidden() in latest revision
-rw-r--r--core/modules/content_moderation/content_moderation.module4
-rw-r--r--core/modules/content_moderation/src/Access/LatestRevisionCheck.php2
-rw-r--r--core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php2
-rw-r--r--core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php2
4 files changed, 5 insertions, 5 deletions
diff --git a/core/modules/content_moderation/content_moderation.module b/core/modules/content_moderation/content_moderation.module
index 4b07e45..3481c24 100644
--- a/core/modules/content_moderation/content_moderation.module
+++ b/core/modules/content_moderation/content_moderation.module
@@ -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.');
}
}
diff --git a/core/modules/content_moderation/src/Access/LatestRevisionCheck.php b/core/modules/content_moderation/src/Access/LatestRevisionCheck.php
index e171939..e470237 100644
--- a/core/modules/content_moderation/src/Access/LatestRevisionCheck.php
+++ b/core/modules/content_moderation/src/Access/LatestRevisionCheck.php
@@ -68,7 +68,7 @@ class LatestRevisionCheck implements AccessInterface {
return $access_result->addCacheableDependency($entity);
}
- return AccessResult::forbidden()->addCacheableDependency($entity);
+ return AccessResult::forbidden('No pending revision for moderated entity.')->addCacheableDependency($entity);
}
/**
diff --git a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php
index 6a707e8..d09c6a5 100644
--- a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php
+++ b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php
@@ -75,7 +75,7 @@ class ModerationOptOutPublish extends PublishAction implements ContainerFactoryP
$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);
diff --git a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php
index 5a46b3e..7f9fa83 100644
--- a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php
+++ b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php
@@ -75,7 +75,7 @@ class ModerationOptOutUnpublish extends UnpublishAction implements ContainerFact
$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);