Skip to content

Instantly share code, notes, and snippets.

@gargsuchi
Created April 10, 2017 07:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gargsuchi/e2f492b0586900e152f0d86c951f398d to your computer and use it in GitHub Desktop.
Save gargsuchi/e2f492b0586900e152f0d86c951f398d to your computer and use it in GitHub Desktop.
function lotus_cron() {
$result = \Drupal::entityQuery("node")
->condition('created', strtotime('-30 days'), '<=')
->execute();
$storage_handler = \Drupal::entityTypeManager()->getStorage("node");
$entities = $storage_handler->loadMultiple($result);
$storage_handler->delete($entities);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment