public static function LingotekSync::updateNotifyUrl in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::updateNotifyUrl()
- 7.3 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::updateNotifyUrl()
- 7.4 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::updateNotifyUrl()
- 7.5 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::updateNotifyUrl()
2 calls to LingotekSync::updateNotifyUrl()
- lingotek_notify_url_update in ./
lingotek.sync.inc - Update the Notify URL (via API)
- lingotek_update_7404 in ./
lingotek.install - Upgrade the callback URL signature and adds translation profiles.
File
- lib/
Drupal/ lingotek/ LingotekSync.php, line 909 - LingotekSync
Class
- LingotekSync
- A utility class for Lingotek Syncing.
Code
public static function updateNotifyUrl() {
$security_token = md5(time());
$new_url = lingotek_notify_url_generate($security_token);
$api = LingotekApi::instance();
$integration_method_id = variable_get('lingotek_integration_method', '');
if (!strlen($integration_method_id)) {
// request integration id when not already set, attempt to detect
$params = array(
'regex' => ".*",
);
$response = $api
->request('searchOutboundIntegrationUrls', $params);
if (isset($response->results) && $response->results) {
global $base_url;
$integration_methods = $response->integrationMethods;
foreach ($integration_methods as $integration_method) {
if (strpos($integration_method->url, $base_url) !== FALSE) {
$integration_method_id = $integration_method->id;
// prefer integration with matching base_url
}
}
if (!strlen($integration_method_id)) {
reset($integration_methods);
// just in case the internal pointer is not pointing to the first element
$integration_method = current($integration_methods);
// grab the first element in the list
$integration_method_id = $integration_method->id;
// use the first url found (if no matching url was found previously)
}
variable_set('lingotek_integration_method', $integration_method_id);
}
}
$parameters = array(
'id' => $integration_method_id,
'url' => $new_url,
);
$response = $api
->request('updateOutboundIntegrationUrl', $parameters);
$success = isset($response->results) ? $response->results : FALSE;
if ($success) {
variable_set('lingotek_notify_url', $new_url);
variable_set('lingotek_notify_security_token', $security_token);
}
return $success;
}