Created
April 10, 2017 19:21
-
-
Save jazzslider/baa52121da0dcbad1ea16a2f7359b8f7 to your computer and use it in GitHub Desktop.
OldNodesService
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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