You are here

public function WebformExampleRemotePostController::index in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_example_remote_post/src/Controller/WebformExampleRemotePostController.php \Drupal\webform_example_remote_post\Controller\WebformExampleRemotePostController::index()

Returns a remote post response.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request.

string $type: Type of remote post request (completed, updated, or deleted)

Return value

\Symfony\Component\HttpFoundation\JsonResponse A JSON response with request status and message.

1 string reference to 'WebformExampleRemotePostController::index'
webform_example_remote_post.routing.yml in modules/webform_example_remote_post/webform_example_remote_post.routing.yml
modules/webform_example_remote_post/webform_example_remote_post.routing.yml

File

modules/webform_example_remote_post/src/Controller/WebformExampleRemotePostController.php, line 26

Class

WebformExampleRemotePostController
Provides route responses for example remote post.

Namespace

Drupal\webform_example_remote_post\Controller

Code

public function index(Request $request, $type) {
  $random = new Random();
  $json = [
    'status' => 'success',
    'message' => (string) $this
      ->t('Processed @type request.', [
      '@type' => $type,
    ]),
    'confirmation_number' => $random
      ->name(20, TRUE),
  ];
  return new JsonResponse($json, 200);
}