Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Entity_Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,21 @@ public static function __callStatic($name, $arguments) {
}

public static function load($ids) {
$ids = (array) $ids;
if (empty($ids)) {
return [];
}

$ds = static::getDataSource();
return $ds->getEntities(get_called_class(), (array) $ids);
return $ds->getEntities(get_called_class(), $ids);
}

public static function loadProgressive($ids, $eagerFetchProperties = [], $context = null, $contextData = []) {
$ids = (array) $ids;
if (empty($ids)) {
return [];
}

# Eager load in progressive selects
$ds = static::getDataSource();

Expand All @@ -261,13 +271,13 @@ public static function loadProgressive($ids, $eagerFetchProperties = [], $contex

// Add additional contextData if present
$where = $contextData + $where;
$entities = call_user_func_array([$ds, 'getDependents'], [get_called_class(), (array) $ids, 'Entity_' . $type, $where, $order, $limit, $count]);
$entities = call_user_func_array([$ds, 'getDependents'], [get_called_class(), $ids, 'Entity_' . $type, $where, $order, $limit, $count]);

// Need to make sure this is an array of objects or just null
$entities = is_object($entities) ? [$entities] : $entities;
}
else {
$entities = $ds->getEntities(get_called_class(), (array) $ids);
$entities = $ds->getEntities(get_called_class(), $ids);
}

// Eager load properties relying on good old recursion to traverse
Expand Down Expand Up @@ -563,4 +573,4 @@ function($config, $dependent) use ($thisClass) {
false
);
}
}
}