protected function LingotekContentTranslationForm::addOperationLink in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8 src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 8.2 src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 4.0.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 3.0.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 3.1.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 3.2.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 3.3.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 3.5.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 3.6.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 3.7.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
- 3.8.x src/Form/LingotekContentTranslationForm.php \Drupal\lingotek\Form\LingotekContentTranslationForm::addOperationLink()
Add an operation to the list of available operations for each language.
1 call to LingotekContentTranslationForm::addOperationLink()
- LingotekContentTranslationForm::buildForm in src/
Form/ LingotekContentTranslationForm.php - Form constructor.
File
- src/
Form/ LingotekContentTranslationForm.php, line 231
Class
Namespace
Drupal\lingotek\FormCode
protected function addOperationLink(ContentEntityInterface $entity, array &$option, $name, $path, LanguageInterface $language, $first = FALSE) {
$operation_col = $this
->getOperationColumnId($entity, $option);
$open_in_window = FALSE;
if (!isset($option[$operation_col]['data']['#links'])) {
$option[$operation_col]['data']['#links'] = [];
}
if (is_string($path)) {
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', [
'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', [
'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', [
'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', [
'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', [
'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', [
'doc_id' => $doc_id,
'locale' => $locale,
]);
$open_in_window = TRUE;
}
else {
die("failed to get known operation in addOperationLink: {$path}");
}
}
else {
$url = $path;
}
if ($first) {
$previous = $option[$operation_col]['data']['#links'];
$option[$operation_col]['data']['#links'] = [];
$option[$operation_col]['data']['#links'][strtolower($name)] = [
'title' => $name,
'url' => $url,
];
$option[$operation_col]['data']['#links'] += $previous;
}
else {
$option[$operation_col]['data']['#links'][strtolower($name)] = [
'title' => $name,
'url' => $url,
];
}
if ($open_in_window) {
$option[$operation_col]['data']['#links'][strtolower($name)]['attributes']['target'] = '_blank';
}
}