You are here

public function LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded in Lingotek Translation 3.1.x

Same name and namespace in other branches
  1. 8.2 src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()
  2. 4.0.x src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()
  3. 3.2.x src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()
  4. 3.3.x src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()
  5. 3.4.x src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()
  6. 3.5.x src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()
  7. 3.6.x src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()
  8. 3.7.x src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()
  9. 3.8.x src/Moderation/LingotekWorkbenchModerationHandler.php \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler::performModerationTransitionIfNeeded()

Performs a moderation transition if needed.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The content entity.

Overrides LingotekModerationHandlerInterface::performModerationTransitionIfNeeded

File

src/Moderation/LingotekWorkbenchModerationHandler.php, line 85

Class

LingotekWorkbenchModerationHandler
Workbench moderation handler managing the Lingotek integration.

Namespace

Drupal\lingotek\Moderation

Code

public function performModerationTransitionIfNeeded(ContentEntityInterface &$entity) {
  if ($this->moderationInfo
    ->isModeratableBundle($entity
    ->getEntityType(), $entity
    ->bundle())) {
    $transition = $this->moderationConfiguration
      ->getDownloadTransition($entity
      ->getEntityTypeId(), $entity
      ->bundle());
    if ($transition !== NULL) {
      $transition = $this->entityTypeManager
        ->getStorage('moderation_state_transition')
        ->load($transition);
      if ($transition !== NULL) {

        // Ensure we can execute this transition.
        if ($this
          ->getModerationState($entity) === $transition
          ->getFromState()) {
          $this
            ->setModerationState($entity, $transition
            ->getToState());
        }
      }
    }
  }
}