YamlFormTestRemotePostController.php in YAML Form 8
File
tests/modules/yamlform_test/src/Controller/YamlFormTestRemotePostController.php
View source
<?php
namespace Drupal\yamlform_test\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
class YamlFormTestRemotePostController extends ControllerBase {
public function index(Request $request, $type) {
$post_data = $request->request
->all();
if (strpos(print_r($post_data, TRUE), 'FAIL') !== FALSE) {
$json = [
'status' => 'fail',
'message' => (string) $this
->t('Failed to process @type request.', [
'@type' => $type,
]),
];
return new JsonResponse($json, 500);
}
else {
$json = [
'status' => 'success',
'message' => (string) $this
->t('Processed @type request.', [
'@type' => $type,
]),
];
return new JsonResponse($json, 200);
}
}
}