You are here

public function GoogleTranslatorTestController::trigger_response_error in TMGMT Translator Google 8

Helper to trigger mok response error.

Parameters

string $domain:

string $reason:

string $message:

string $locationType:

string $location:

2 calls to GoogleTranslatorTestController::trigger_response_error()
GoogleTranslatorTestController::translate in tmgmt_google_test/src/Controller/GoogleTranslatorTestController.php
Mok service to translate request.
GoogleTranslatorTestController::validateKey in tmgmt_google_test/src/Controller/GoogleTranslatorTestController.php
Key validator helper.

File

tmgmt_google_test/src/Controller/GoogleTranslatorTestController.php, line 57
Contains \Drupal\block\Controller\CategoryAutocompleteController.

Class

GoogleTranslatorTestController
Returns autocomplete responses for block categories.

Namespace

Drupal\tmgmt_google_test\Controller

Code

public function trigger_response_error($domain, $reason, $message, $locationType = NULL, $location = NULL) {
  $response = array(
    'error' => array(
      'errors' => array(
        'domain' => $domain,
        'reason' => $reason,
        'message' => $message,
      ),
      'code' => 400,
      'message' => $message,
    ),
  );
  if (!empty($locationType)) {
    $response['error']['errors']['locationType'] = $locationType;
  }
  if (!empty($location)) {
    $response['error']['errors']['location'] = $location;
  }
  return new JsonResponse($response);
}