diff --git a/core/modules/content_moderation/content_moderation.module b/core/modules/content_moderation/content_moderation.module index 4b07e45790b44deab1f302bc8a3eeeb27e6990bd..3481c243e186d1bd829a9ab568923126968e53ed 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 e1719396d40d30f3592828892c3a7994defa593c..e470237448e9f8ba8097564b946380a0cdf4a335 100644 --- a/core/modules/content_moderation/src/Access/LatestRevisionCheck.php +++ b/core/modules/content_moderation/src/Access/LatestRevisionCheck.php @@ -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); } /** diff --git a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php index 6a707e852fdcb844e50e1b650bc8a06ce15997b7..d09c6a5f46c0098f1b1e5e01f2345280041517be 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 @@ 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); diff --git a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php index 5a46b3e34122db6e849233ead8dde1850ef5896f..7f9fa83bb3415cc191246f025b59f1d4db761862 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 @@ 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);