You are here

protected function LingotekContentTranslationForm::addOperationLink in Lingotek Translation 8

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

File

src/Form/LingotekContentTranslationForm.php, line 224
Contains \Drupal\lingotek\Form\LingotekContentTranslationForm.

Class

LingotekContentTranslationForm

Namespace

Drupal\lingotek\Form

Code

protected function addOperationLink(ContentEntityInterface $entity, array &$option, $name, $path, LanguageInterface $language) {
  $operation_col = $this
    ->getOperationColumnId($entity, $option);
  $open_in_window = FALSE;
  if (!isset($option[$operation_col]['data']['#links'])) {
    $option[$operation_col]['data']['#links'] = array();
  }
  if (strpos($path, '/admin/lingotek/batch/') === 0) {
    $path = str_replace('/admin/lingotek/batch/', '', $path);
    list($action, $entity_type, $entity_id) = explode('/', $path);
    $url = Url::fromRoute('lingotek.batch', array(
      'action' => $action,
      'entity_type' => $entity_type,
      'entity_id' => $entity_id,
    ));
  }
  elseif (strpos($path, '/admin/lingotek/entity/check_upload/') === 0) {
    $doc_id = str_replace('/admin/lingotek/entity/check_upload/', '', $path);
    $url = Url::fromRoute('lingotek.entity.check_upload', array(
      'doc_id' => $doc_id,
    ));
  }
  elseif (strpos($path, '/admin/lingotek/entity/add_target/') === 0) {
    $path = str_replace('/admin/lingotek/entity/add_target/', '', $path);
    list($doc_id, $locale) = explode('/', $path);
    $url = Url::fromRoute('lingotek.entity.request_translation', array(
      'doc_id' => $doc_id,
      'locale' => $locale,
    ));
  }
  elseif (strpos($path, '/admin/lingotek/entity/check_target/') === 0) {
    $path = str_replace('/admin/lingotek/entity/check_target/', '', $path);
    list($doc_id, $locale) = explode('/', $path);
    $url = Url::fromRoute('lingotek.entity.check_target', array(
      'doc_id' => $doc_id,
      'locale' => $locale,
    ));
  }
  elseif (strpos($path, '/admin/lingotek/entity/download/') === 0) {
    $path = str_replace('/admin/lingotek/entity/download/', '', $path);
    list($doc_id, $locale) = explode('/', $path);
    $url = Url::fromRoute('lingotek.entity.download', array(
      'doc_id' => $doc_id,
      'locale' => $locale,
    ));
  }
  elseif (strpos($path, '/admin/lingotek/workbench/') === 0) {
    $path = str_replace('/admin/lingotek/workbench/', '', $path);
    list($doc_id, $locale) = explode('/', $path);
    $url = Url::fromRoute('lingotek.workbench', array(
      'doc_id' => $doc_id,
      'locale' => $locale,
    ));
    $open_in_window = TRUE;
  }
  else {
    die("failed to get known operation in addOperationLink: {$path}");
  }
  $option[$operation_col]['data']['#links'][strtolower($name)] = array(
    'title' => $name,
    'language' => $language,
    'url' => $url,
  );
  if ($open_in_window) {
    $option[$operation_col]['data']['#links'][strtolower($name)]['attributes']['target'] = '_blank';
  }
}