You are here

public function LingotekHttp::post in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  2. 4.0.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  3. 3.0.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  4. 3.1.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  5. 3.2.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  6. 3.3.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  7. 3.4.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  8. 3.5.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  9. 3.6.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  10. 3.7.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
  11. 3.8.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()

Overrides LingotekHttpInterface::post

File

src/Remote/LingotekHttp.php, line 61

Class

LingotekHttp

Namespace

Drupal\lingotek\Remote

Code

public function post($path, $args = array(), $use_multipart = FALSE) {
  $options = [];
  if (count($args) && $use_multipart) {
    $multipart = [];
    foreach ($args as $name => $contents) {
      $multipart[] = [
        'name' => $name,
        'contents' => $contents,
      ];
    }
    $options[RequestOptions::MULTIPART] = $multipart;
  }
  elseif (count($args) && !$use_multipart) {
    $options[RequestOptions::FORM_PARAMS] = $args;
  }
  return $this->httpClient
    ->post($this
    ->getBaseUrl() . $path, [
    RequestOptions::HEADERS => $this
      ->getDefaultHeaders(),
  ] + $options);
}