Skip to content

Instantly share code, notes, and snippets.

@jazzslider
Created April 10, 2017 19:21
Show Gist options
  • Save jazzslider/baa52121da0dcbad1ea16a2f7359b8f7 to your computer and use it in GitHub Desktop.
Save jazzslider/baa52121da0dcbad1ea16a2f7359b8f7 to your computer and use it in GitHub Desktop.
OldNodesService
<?php
namespace Drupal\lotus;
use Drupal\Core\Entity\EntityTypeManager;
class OldNodesService {
protected $entityTypeManager;
public function __construct(EntityTypeManager $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
public function load() {
$storage = $this->entityTypeManager->getStorage('node');
$query = $storage->getQuery()
->condition('created', strtotime('-30 days'), '<');
$nids = $query->execute();
return $storage->loadMultiple($nids);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment