NodeModerationHandler::shouldModerate

protected NodeModerationHandler::shouldModerate(ContentEntityInterface $entity, $published_state)

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

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to check.

bool $published_state: Whether the state being transitioned to is a published state or not.

Return value

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

File

core/modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php, line 59

Class

NodeModerationHandler
Customizations for node entities.

Namespace

Drupal\content_moderation\Entity\Handler

Code

protected function shouldModerate(ContentEntityInterface $entity, $published_state) {
  // @todo clarify the first condition.
  // 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->isPublished() !== $published_state;
}
doc_Drupal
2016-10-29 09:31:01
Comments
Leave a Comment

Please login to continue.