public function ListenerPageController::content in Evercurrent 8
Same name and namespace in other branches
- 8.2 src/Controller/ListenerPageController.php \Drupal\evercurrent\Controller\ListenerPageController::content()
1 string reference to 'ListenerPageController::content'
File
- src/
Controller/ ListenerPageController.php, line 33 - Contains \Drupal\example\Controller\ExamleController.
Class
- ListenerPageController
- Creates a callback for listening to the server.
Namespace
Drupal\evercurrent\ControllerCode
public function content() {
$received = json_decode($_POST['data'], TRUE);
$updateHelper = \Drupal::service('evercurrent.update_helper');
// No key equals error response.
if (!isset($received['key'])) {
$severity = RMH_STATUS_ERROR;
$message = 'Received an invalid request in listening mode.';
$updateHelper
->writeStatus($severity, $message, $output = FALSE);
return $this
->jsonResponse('Malformed data.', 'error');
}
$key = $received['key'];
$result = $updateHelper
->testUpdate($key);
if ($result == TRUE) {
$this
->jsonResponse('Success.', 'status');
}
else {
$this
->jsonResponse('Unknown error.', 'error');
}
return $this
->jsonResponse('Can you see this message?', 'error');
}