You are here

public function TestController::deleteHeartbeats in Heartbeat 8

1 string reference to 'TestController::deleteHeartbeats'
heartbeat.routing.yml in ./heartbeat.routing.yml
heartbeat.routing.yml

File

src/Controller/TestController.php, line 163

Class

TestController
Class TestController.

Namespace

Drupal\heartbeat\Controller

Code

public function deleteHeartbeats() {
  $entities = \Drupal::service("entity.query")
    ->get("heartbeat")
    ->execute();
  foreach ($entities as $entity) {
    $heartbeat = \Drupal::service("entity_type.manager")
      ->getStorage("heartbeat")
      ->load($entity);
    $heartbeat
      ->delete();
  }
  return [
    '#type' => 'markup',
    '#markup' => $this
      ->t('Deleting them Heartbeats'),
  ];
}