You are here

protected function BaseApiAbstract::processBodyOptions in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.2 api-sdk-php/src/BaseApiAbstract.php \Smartling\BaseApiAbstract::processBodyOptions()
  2. 8.2 vendor/smartling/api-sdk-php/src/BaseApiAbstract.php \Smartling\BaseApiAbstract::processBodyOptions()
  3. 8.3 vendor/smartling/api-sdk-php/src/BaseApiAbstract.php \Smartling\BaseApiAbstract::processBodyOptions()

Parameters

mixed $requestData:

Return value

array

4 calls to BaseApiAbstract::processBodyOptions()
BaseApiAbstract::sendRequest in vendor/smartling/api-sdk-php/src/BaseApiAbstract.php
BatchApi::processBodyOptions in vendor/smartling/api-sdk-php/src/Batch/BatchApi.php
ContextApi::processBodyOptions in vendor/smartling/api-sdk-php/src/Context/ContextApi.php
FileApi::processBodyOptions in vendor/smartling/api-sdk-php/src/File/FileApi.php
3 methods override BaseApiAbstract::processBodyOptions()
BatchApi::processBodyOptions in vendor/smartling/api-sdk-php/src/Batch/BatchApi.php
ContextApi::processBodyOptions in vendor/smartling/api-sdk-php/src/Context/ContextApi.php
FileApi::processBodyOptions in vendor/smartling/api-sdk-php/src/File/FileApi.php

File

vendor/smartling/api-sdk-php/src/BaseApiAbstract.php, line 311

Class

BaseApiAbstract
Class BaseApiAbstract

Namespace

Smartling

Code

protected function processBodyOptions($requestData = []) {
  if (!empty($requestData['multipart'])) {
    $body = [];
    foreach ($requestData['multipart'] as $key => $value) {

      // Hack to cast FALSE to '0' instead of empty string.
      if (is_bool($value)) {
        $value = (int) $value;
      }
      if (is_array($value)) {
        foreach ($value as $_item) {
          $body[] = [
            'name' => $key . '[]',
            'contents' => (string) $_item,
          ];
        }
      }
      else {
        $body[] = [
          'name' => $key,
          'contents' => $value,
        ];
      }
    }
    $requestData['multipart'] = $body;
  }
  return $requestData;
}