You are here

public function ContentService::getRecentContent in Content Planner 8

File

modules/content_calendar/src/ContentService.php, line 32

Class

ContentService
Class UserProfileImage.

Namespace

Drupal\content_calendar

Code

public function getRecentContent($limit) {
  $configs = $this
    ->getContentTypeConfig();
  $types = [];
  if (is_array($configs)) {
    foreach ($configs as $config) {
      $types[] = $config
        ->getOriginalId();
    }
  }
  if (empty($types)) {
    return [];
  }
  $ids = \Drupal::entityQuery('node')
    ->condition('status', 1)
    ->condition('type', $types, 'IN')
    ->sort('created', 'DESC')
    ->range(0, $limit)
    ->execute();
  return $nodes = Node::loadMultiple($ids);
}