public static function LingotekSync::updateNotifyUrl in Lingotek Translation 7.4
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.5 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::updateNotifyUrl()
- 7.6 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 937
- 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)) {
$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;
}
}
if (!strlen($integration_method_id)) {
reset($integration_methods);
$integration_method = current($integration_methods);
$integration_method_id = $integration_method->id;
}
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;
}