public function RestfulDataProviderDbQuery::viewMultiple in RESTful 7
View a collection of items.
Parameters
array $ids: An array of items to view.
Return value
array The structured array ready to be rendered.
Overrides RestfulBase::viewMultiple
1 call to RestfulDataProviderDbQuery::viewMultiple()
- RestfulDataProviderDbQuery::view in plugins/
restful/ RestfulDataProviderDbQuery.php - View an item from the data source.
File
- plugins/
restful/ RestfulDataProviderDbQuery.php, line 339 - Contains \RestfulDataProviderDbQuery
Class
- RestfulDataProviderDbQuery
- @file Contains \RestfulDataProviderDbQuery
Code
public function viewMultiple(array $ids) {
$cache_id = array(
'tb' => $this
->getTableName(),
'cl' => implode(',', $this
->getIdColumn()),
'id' => implode(',', $ids),
);
$cached_data = $this
->getRenderedCache($cache_id);
if (!empty($cached_data->data)) {
return $cached_data->data;
}
// Get a list query with all the sorting and pagination in place.
$query = $this
->getQueryForList();
if (empty($ids)) {
return array();
}
foreach ($this
->getIdColumn() as $index => $column) {
$query
->condition($this
->getTableName() . '.' . $column, $this
->getColumnFromIds($ids, $index), 'IN');
}
$results = $query
->execute();
$return = array();
foreach ($results as $result) {
$return[] = $this
->mapDbRowToPublicFields($result);
}
$this
->setRenderedCache($return, $cache_id);
return $return;
}