You are here

public function RestProcessor::processData in Radioactivity 8.3

Same name and namespace in other branches
  1. 4.0.x src/RestProcessor.php \Drupal\radioactivity\RestProcessor::processData()

Processes incoming radioactivity incident data.

Parameters

string $data: Json formatted incident data. The format must match the return value of \Drupal\radioactivity\Incident::toJson.

Return value

string Json formatted result status message.

File

src/RestProcessor.php, line 51

Class

RestProcessor
The worker class for the Radioactivity rest endpoint.

Namespace

Drupal\radioactivity

Code

public function processData($data) {
  if (!$this
    ->verifyData($data)) {
    return $this
      ->restStatus('error', 'Invalid json.');
  }
  $fh = fopen($this->payloadFile, 'a+');
  fwrite($fh, $data . ',' . PHP_EOL);
  fclose($fh);
  return $this
    ->restStatus('ok', 'Inserted.');
}