You are here

public function Incident::toJson in Radioactivity 4.0.x

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

Convert to JSON format.

Return value

string Json encoded incident data.

Overrides IncidentInterface::toJson

File

src/Incident.php, line 109

Class

Incident
Data class for Radioactivity Incident.

Namespace

Drupal\radioactivity

Code

public function toJson() {
  return Json::encode([
    'fn' => $this->fieldName,
    'et' => $this->entityType,
    'id' => $this->entityId,
    'ti' => $this->targetId,
    'e' => $this->energy,
    'h' => $this
      ->calculateHash(),
  ]);
}