sammarks / ablecore

A library for Drupal developers.
MIT License
5 stars 4 forks source link

Add Entity::map() function. #13

Closed sammarks closed 10 years ago

sammarks commented 10 years ago

This function will have the following definition:

Entity::map(string $entity_type, array $entity_ids);

It will load all the entities given in the $entity_ids array, and return an array of the loaded entities. This is meant to shorten code like this:

$nids = $query->execute()->fetchCol();
$nodes = array();
foreach ($nids as $nid) {
    $nodes[] = AbleCore\Node::load($nid);
}

Into code like this:

$nodes = AbleCore\Entity::map('node', $query->execute()->fetchCol();