diff --git a/core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php b/core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php index f76c573..62e504e 100644 --- a/core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php +++ b/core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php @@ -34,30 +34,13 @@ public function onPresave(ContentEntityInterface $entity, $default_revision, $pu $entity->setNewRevision(TRUE); $entity->isDefaultRevision($default_revision); - if ($this->shouldModerate($entity, $published_state)) { + // Update publishing status if it can be updated and if it needs updating. + if (($entity instanceof EntityPublishedInterface) && $entity->isPublished() !== $published_state) { $published_state ? $entity->setPublished() : $entity->setUnpublished(); } } /** - * Check if an entity's default revision and/or state needs adjusting. - * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity - * The entity to check. - * @param bool $published_state - * Whether the state being transitioned to is a published state or not. - * - * @return bool - * TRUE when either the default revision or the state needs to be updated. - */ - protected function shouldModerate(ContentEntityInterface $entity, $published_state) { - // @todo clarify the first condition, https://www.drupal.org/node/2834953. - // First condition is needed so you can add a translation. - // Second condition checks to see if the published status has changed. - return $entity->isDefaultTranslation() || (($entity instanceof EntityPublishedInterface) && $entity->isPublished() !== $published_state); - } - - /** * {@inheritdoc} */ public function enforceRevisionsEntityFormAlter(array &$form, FormStateInterface $form_state, $form_id) {