public function TestController::saveHeartbeats in Heartbeat 8
1 string reference to 'TestController::saveHeartbeats'
File
- src/
Controller/ TestController.php, line 65
Class
- TestController
- Class TestController.
Namespace
Drupal\heartbeat\ControllerCode
public function saveHeartbeats() {
$heartbeats = $this->entityQuery
->get("heartbeat")
->execute();
$data = array();
foreach ($heartbeats as $hid) {
$beat = $this->entityTypeManager
->getStorage("heartbeat")
->load($hid);
$data[] = $beat;
}
$result = '';
$result = file_put_contents("public://heartbeats.dat", serialize($data)) ? 'Saved Heartbeats' : 'Error saving heartbeats';
return [
'#type' => 'markup',
'#markup' => $this
->t($result),
];
}