You are here

public static function Incident::createFromPostData in Radioactivity 8.3

Same name and namespace in other branches
  1. 8.2 src/Incident.php \Drupal\radioactivity\Incident::createFromPostData()
  2. 4.0.x src/Incident.php \Drupal\radioactivity\Incident::createFromPostData()

Create an Incident from data received in an http request.

Parameters

array $data: Associative array of incident data.

Return value

\Drupal\radioactivity\IncidentInterface An Incident object.

3 calls to Incident::createFromPostData()
EmitController::emit in src/Controller/EmitController.php
Callback for /radioactivity/emit.
IncidentTest::testCreateFromPostData in tests/src/Unit/IncidentTest.php
@covers ::createFromPostData
RestIncidentStorage::getIncidents in src/RestIncidentStorage.php
Gets all incidents from the storage.

File

src/Incident.php, line 117

Class

Incident
Data class for Radioactivity Incident.

Namespace

Drupal\radioactivity

Code

public static function createFromPostData(array $data) {
  $data += [
    'fn' => '',
    'et' => '',
    'id' => '',
    'e' => 0,
    'h' => '',
  ];
  return new Incident($data['fn'], $data['et'], $data['id'], $data['e'], $data['h']);
}