You are here

protected function LingotekSettingsTabProfilesForm::retrieveActions in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 8 src/Form/LingotekSettingsTabProfilesForm.php \Drupal\lingotek\Form\LingotekSettingsTabProfilesForm::retrieveActions()
1 call to LingotekSettingsTabProfilesForm::retrieveActions()
LingotekSettingsTabProfilesForm::buildForm in src/Form/LingotekSettingsTabProfilesForm.php
Form constructor.

File

src/Form/LingotekSettingsTabProfilesForm.php, line 92

Class

LingotekSettingsTabProfilesForm
Configure Lingotek

Namespace

Drupal\lingotek\Form

Code

protected function retrieveActions($profile = NULL, $usage = NULL) {

  // Assign $url and $title depending on if it's a new profile or not
  if ($profile) {
    $title = t('Edit');
    $url = Url::fromRoute('lingotek.settings_profile', [
      'profile_choice' => $profile,
      'profile_index' => $this->profile_index,
      'profile_usage' => $usage,
    ]);
  }
  else {
    $title = t('Add New Profile');
    $url = Url::fromRoute('entity.lingotek_profile.add_form');
  }

  // If it's a disabled profile, no link is provided
  if ($profile['id'] == Lingotek::PROFILE_DISABLED) {
    $edit_link = [
      '#markup' => $this
        ->t('Not Editable'),
    ];
  }
  else {
    $edit_link = [
      '#type' => 'link',
      '#title' => $title,
      '#url' => $url,
      '#ajax' => [
        'class' => [
          'use-ajax',
        ],
      ],
      '#attributes' => [
        'class' => [
          'use-ajax',
        ],
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode([
          'width' => 861,
          'height' => 700,
        ]),
      ],
    ];
  }
  return $edit_link;
}