$target_entities = \Drupal::
entityTypeManager()->
getStorage($target_type)->
loadMultiple($ids);
} // For each item, pre-populate the loaded entity in $item->entity, and set
// the 'loaded' flag.
foreach ($entities_items as $items) { foreach ($items as $item) { if (isset($target_entities[$item->target_id
])) { $item->entity =
$target_entities[$item->target_id
];
$item->_loaded = TRUE;
} elseif ($item->
hasNewEntity()) { $item->_loaded = TRUE;
} } } } /**
* Returns whether the entity referenced by an item needs to be loaded.
*
* @param \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $item
* The item to check.
*
* @return bool
* TRUE if the entity needs to be loaded.
*/