entityTypeManager = \Drupal::entityTypeManager(); } /** * Compute the values. */ protected function computeValue() { $query = \Drupal::entityQuery('node') ->condition('status', 1) ->sort('created', 'DESC') ->exists('field_visuel') ->range(0,12) ->condition('type', 'article'); $nids = $query->execute(); $i = 0; foreach ($nids as $nid) { $this->list[$i] = $this->createItem($i, $nid); $i++; } } }