You are here

protected function LingotekSettingsTabProfilesForm::retrieveActions in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 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 96
Contains \Drupal\lingotek\Form\LingotekSettingsProfilesForm.

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 = array(
      '#markup' => $this
        ->t('Not Editable'),
    );
  }
  else {
    $edit_link = array(
      '#type' => 'link',
      '#title' => $title,
      '#url' => $url,
      '#ajax' => array(
        'class' => array(
          'use-ajax',
        ),
      ),
      '#attributes' => array(
        'class' => array(
          'use-ajax',
        ),
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode(array(
          'width' => 861,
          'height' => 700,
        )),
      ),
    );
  }
  return $edit_link;
}