diff --git a/src/Entity_Abstract.php b/src/Entity_Abstract.php index fb8d7b3..68dbc9e 100644 --- a/src/Entity_Abstract.php +++ b/src/Entity_Abstract.php @@ -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(); @@ -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 @@ -563,4 +573,4 @@ function($config, $dependent) use ($thisClass) { false ); } -} \ No newline at end of file +}