public function entity_moderation_status(EntityInterface $entity) {
    $moderation_module = $this->active_moderation_module();
    if ($this->moduleHandler->moduleExists($moderation_module)) {
      $moderation_info = \Drupal::service($moderation_module . '.moderation_information');
      // Check that entity bundle support moderation.
      if ($moderation_info->getWorkflowForEntity($entity)) {
        // Contains checking:
        // isLatestRevision, isDefaultRevision, isPublishedState.
        return $moderation_info->isLiveRevision($entity);
      }
    }

    // Fallback to is isPublished & isDefaultRevision.
    return ($entity->isPublished() && $entity->isDefaultRevision());
  }
public function entity_moderation_status(EntityInterface $entity) {
    $moderation_module = $this->active_moderation_module();
    if ($this->moduleHandler->moduleExists($moderation_module)) {
      $moderation_info = \Drupal::service($moderation_module . '.moderation_information');
      // Check that entity bundle support moderation.
      if ($moderation_info->getWorkflowForEntity($entity)) {
        // Contains checking:
        // isLatestRevision, isDefaultRevision, isPublishedState.
        return $moderation_info->isLiveRevision($entity);
      }
    }

    // Fallback to is isPublished & isDefaultRevision.
    return ($entity->isPublished() && $entity->isDefaultRevision());
  }
public function entity_moderation_status ( EntityInterface $ entity ) { $ moderation_module = $ this -> active_moderation_module ( ) ; if ( $ this -> moduleHandler -> moduleExists ( $ moderation_module ) ) { $ moderation_info = \ Drupal :: service ( $ moderation_module . '.moderation_information' ) ; // Check that entity bundle support moderation. if ( $ moderation_info -> getWorkflowForEntity ( $ entity ) ) { // Contains checking: // isLatestRevision, isDefaultRevision, isPublishedState. return $ moderation_info -> isLiveRevision ( $ entity ) ; } } // Fallback to is isPublished & isDefaultRevision. return ( $ entity -> isPublished ( ) && $ entity -> isDefaultRevision ( ) ) ; }
Check entity moderation status.

This is helper method with content moderation status checking.
If in the future content moderation will be replace workbench_moderation,
please update openy_moderation_wrapper.settings -> moderation_module
configuration.

@param \Drupal\Core\Entity\EntityInterface $entity
Entity.

@return bool
TRUE if entity is published.
Check entity moderation status .