You are here

public function LingotekWorkbenchModerationSettingsForm::getDefaultModerationDownloadTransition in Lingotek Translation 3.3.x

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

Gets the default transition.

Parameters

string $entity_type_id: The entity type id.

string $bundle: The bundle id.

Return value

string The default transition ID. If there is a setting, that will be returned.

Overrides LingotekModerationSettingsFormInterface::getDefaultModerationDownloadTransition

1 call to LingotekWorkbenchModerationSettingsForm::getDefaultModerationDownloadTransition()
LingotekWorkbenchModerationSettingsForm::form in src/Moderation/LingotekWorkbenchModerationSettingsForm.php
Gets the subform for configuring the settings for a given bundle.

File

src/Moderation/LingotekWorkbenchModerationSettingsForm.php, line 137

Class

LingotekWorkbenchModerationSettingsForm
Moderation settings form for the Lingotek workbench_moderation integration.

Namespace

Drupal\lingotek\Moderation

Code

public function getDefaultModerationDownloadTransition($entity_type_id, $bundle) {
  $transition = $this->moderationConfiguration
    ->getDownloadTransition($entity_type_id, $bundle);
  if (!$transition) {
    $transitions = $this->entityTypeManager
      ->getStorage('moderation_state_transition')
      ->getQuery()
      ->condition('stateFrom', $this
      ->getDefaultModerationUploadStatus($entity_type_id, $bundle))
      ->execute();
    if (count($transitions) > 0) {
      $transitions = $this->entityTypeManager
        ->getStorage('moderation_state_transition')
        ->loadMultiple($transitions);

      /** @var \Drupal\workbench_moderation\ModerationStateTransitionInterface $potential_transition */
      foreach ($transitions as $transition_id => $potential_transition) {

        /** @var \Drupal\workbench_moderation\ModerationStateInterface $toState */
        $toState = $this->entityTypeManager
          ->getStorage('moderation_state')
          ->load($potential_transition
          ->getToState());
        if ($toState
          ->isPublishedState()) {
          $transition = $transition_id;
          break;
        }
      }
    }
  }
  return $transition;
}