You are here

function lingotek_sync_endpoint in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lingotek.sync.inc \lingotek_sync_endpoint()
  2. 7.2 lingotek.sync.inc \lingotek_sync_endpoint()
  3. 7.3 lingotek.sync.inc \lingotek_sync_endpoint()
  4. 7.4 lingotek.sync.inc \lingotek_sync_endpoint()
  5. 7.5 lingotek.sync.inc \lingotek_sync_endpoint()

The API endpoint for bulk translation management

1 string reference to 'lingotek_sync_endpoint'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.sync.inc, line 181
Sync and management

Code

function lingotek_sync_endpoint() {
  $parameters = array();
  $method = $_SERVER['REQUEST_METHOD'];
  $status = "200";
  $request = array(
    'method' => $method,
  );
  $response = array();
  switch ($method) {
    case 'GET':
      $request['parameters'] = $parameters = $_GET;

      /* $request['doc_ids'] = $document_ids = isset($parameters['doc_ids']) ? array_map(function($val) {
         return trim($val);
         }, explode(',', $parameters['doc_ids'])) : array(); */
      $response = LingotekSync::getReport();
      break;
    case 'POST':
    case 'PUT':
    case 'DELETE':
    default:
      parse_str(file_get_contents("php://input"), $parameters);
      $status = "405 Method Not Allowed";
      break;
  }
  return lingotek_json_output_cors($response, $status, array(
    'methods_allowed' => 'GET',
  ));
}