You are here

public function LingotekContentModerationSettingsForm::form in Lingotek Translation 3.2.x

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

Gets the subform for configuring the settings for a given bundle.

Parameters

string $entity_type_id: The entity type id.

string $bundle: The bundle id.

Return value

array The array defining the form.

Overrides LingotekModerationSettingsFormInterface::form

File

src/Moderation/LingotekContentModerationSettingsForm.php, line 251

Class

LingotekContentModerationSettingsForm
Moderation settings form for the Lingotek content_moderation integration.

Namespace

Drupal\lingotek\Moderation

Code

public function form($entity_type_id, $bundle) {

  // We only add this option if the workbench moderation is enabled.
  $entity_type_definition = $this->entityTypeManager
    ->getDefinition($entity_type_id);
  $form = [];
  if ($this->moderationInfo
    ->shouldModerateEntitiesOfBundle($entity_type_definition, $bundle)) {
    $statuses = $this
      ->getModerationUploadStatuses($entity_type_id, $bundle);
    $default_status = $this
      ->getDefaultModerationUploadStatus($entity_type_id, $bundle);
    $transitions = $this
      ->getModerationDownloadTransitions($entity_type_id, $bundle);
    $default_transition = $this
      ->getDefaultModerationDownloadTransition($entity_type_id, $bundle);
    $form['upload_status'] = [
      '#type' => 'select',
      '#options' => $statuses,
      '#default_value' => $default_status,
      '#title' => $this
        ->t('In which status needs to be uploaded?'),
    ];
    $form['download_transition'] = [
      '#type' => 'select',
      '#options' => $transitions,
      '#default_value' => $default_transition,
      '#title' => $this
        ->t('Which transition should be executed after download?'),
    ];
  }
  elseif ($this->moderationInfo
    ->canModerateEntitiesOfEntityType($entity_type_definition)) {
    $form = [
      '#markup' => $this
        ->t('This entity bundle is not enabled for moderation with content_moderation. You can change its settings <a href=":moderation">here</a>.', [
        ':moderation' => $this->urlGenerator
          ->generateFromRoute("entity.workflow.collection"),
      ]),
    ];
  }
  return $form;
}