if (isset($entity->in_preview
) &&
$entity->in_preview
) { return;
} // If the component is not defined for this display, we have nothing to do.
if (!
$display->
getComponent('content_moderation_control'
)) { return;
} // The moderation form should be displayed only when viewing the latest
// (translation-affecting) revision, unless it was created as published
// default revision.
if (($entity->
isDefaultRevision() ||
$entity->
wasDefaultRevision()) &&
$this->
isPublished($entity)) { return;
} if (!
$entity->
isLatestRevision() && !
$entity->
isLatestTranslationAffectedRevision()) { return;
} $build['content_moderation_control'
] =
$this->formBuilder->
getForm(EntityModerationForm::
class,
$entity);
} /**
* Checks if the entity is published.
*
* This method is optimized to not have to unnecessarily load the moderation
* state and workflow if it is not required.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The entity to check.
*
* @return bool
* TRUE if the entity is published, FALSE otherwise.
*/