You are here

private function SmartlingTranslator::getCallbackUrl in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.2 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::getCallbackUrl()
  2. 8.3 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::getCallbackUrl()

Returns callback url.

Host value can be overridden by value defined in translator settings.

Parameters

JobInterface $job:

Return value

Drupal\Core\GeneratedUrl|string

1 call to SmartlingTranslator::getCallbackUrl()
SmartlingTranslator::requestTranslation in src/Plugin/tmgmt/Translator/SmartlingTranslator.php
@abstract

File

src/Plugin/tmgmt/Translator/SmartlingTranslator.php, line 195
Contains \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator.

Class

SmartlingTranslator
Smartling translator plugin.

Namespace

Drupal\tmgmt_smartling\Plugin\tmgmt\Translator

Code

private function getCallbackUrl(JobInterface $job) {
  $callback_url = Url::fromRoute('tmgmt_smartling.push_callback', [
    'job' => $job
      ->id(),
  ])
    ->setOptions([
    'absolute' => TRUE,
  ])
    ->toString();
  $relative_callback_url = Url::fromRoute('tmgmt_smartling.push_callback', [
    'job' => $job
      ->id(),
  ])
    ->toString();
  $callback_url_host = rtrim($job
    ->getTranslator()
    ->getSetting('callback_url_host'), '/');
  if (!empty($callback_url_host)) {
    $callback_url = Url::fromUserInput($relative_callback_url, [
      'base_url' => $callback_url_host,
    ])
      ->toString();
  }
  return $callback_url;
}