You are here

protected function LingotekSettingsTabContentForm::retrieveProfiles in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  2. 8.2 src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  3. 4.0.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  4. 3.0.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  5. 3.1.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  6. 3.2.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  7. 3.3.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  8. 3.5.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  9. 3.6.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  10. 3.7.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
  11. 3.8.x src/Form/LingotekSettingsTabContentForm.php \Drupal\lingotek\Form\LingotekSettingsTabContentForm::retrieveProfiles()
1 call to LingotekSettingsTabContentForm::retrieveProfiles()
LingotekSettingsTabContentForm::buildForm in src/Form/LingotekSettingsTabContentForm.php
Form constructor.

File

src/Form/LingotekSettingsTabContentForm.php, line 297

Class

LingotekSettingsTabContentForm
Configure Lingotek

Namespace

Drupal\lingotek\Form

Code

protected function retrieveProfiles($entity_id, $bundle_id) {

  /** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_config */
  $lingotek_config = \Drupal::service('lingotek.configuration');
  $enable_bulk_management = $lingotek_config
    ->getPreference('contrib.paragraphs.enable_bulk_management');
  if (!in_array($entity_id, [
    'paragraph',
    'cohesion_layout',
  ]) || $enable_bulk_management) {
    $select = [
      '#type' => 'select',
      '#options' => $lingotek_config
        ->getProfileOptions(),
      '#default_value' => $lingotek_config
        ->getDefaultProfileId($entity_id, $bundle_id),
    ];
  }
  elseif ($entity_id === 'paragraph' || $enable_bulk_management) {
    $select = [
      '#markup' => $this
        ->t("A profile doesn't apply for paragraphs. Not recommended, but you may want to <a href=':link'>translate paragraphs independently</a>.", [
        ':link' => '#edit-contrib-paragraphs-enable-bulk-management',
      ]),
    ];
  }
  elseif ($entity_id === 'cohesion_layout') {
    $select = [
      '#markup' => $this
        ->t("A profile doesn't apply for cohesion layouts."),
    ];
  }
  return $select;
}