You are here

protected function NodeModerationHandler::shouldModerate in Workbench Moderation 8.2

Check if an entity's default revision and/or state needs adjusting.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity:

Return value

bool TRUE when either the default revision or the state needs to be updated.

1 call to NodeModerationHandler::shouldModerate()
NodeModerationHandler::onPresave in src/Entity/Handler/NodeModerationHandler.php

File

src/Entity/Handler/NodeModerationHandler.php, line 61
Contains Drupal\workbench_moderation\Entity\Handler\NodeCustomizations.

Class

NodeModerationHandler
Customizations for node entities.

Namespace

Drupal\workbench_moderation\Entity\Handler

Code

protected function shouldModerate(ContentEntityInterface $entity) {

  // First condition is needed so you can add a translation.
  // Second condition is needed when you want to publish a translation.
  // Third condition is needed when you want to create a new draft for a published translation.
  return $entity
    ->isDefaultTranslation() || $entity->moderation_state->entity
    ->isPublishedState() || $entity
    ->isPublished();
}