Skip to content
Open
Show file tree
Hide file tree
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
23 changes: 15 additions & 8 deletions src/Plugin/resource/DataProvider/CacheDecoratedDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,29 @@ public function view($identifier) {

/**
* {@inheritdoc}
*
* @throws \Exception
* In case there's no content to show, and some exceptions where thrown
* from view(), then the last exception will be thrown.
*/
public function viewMultiple(array $identifiers) {
$return = array();
// If no IDs were requested, we should not throw an exception in case an
// entity is un-accessible by the user.
$rows = array();

foreach ($identifiers as $identifier) {
try {
$row = $this->view($identifier);
$rows[] = $this->view($identifier);
}
catch (InaccessibleRecordException $e) {
$row = NULL;
catch (\Exception $e) {
// Ignore the exceptions in case some content is visible, to allow
// partial success.
}
$return[] = $row;
}
if (!$rows && isset($e)) {
// Re-through the last exception in case no content is visible.
throw $e;
}

return array_values(array_filter($return));
return $rows;
}

/**
Expand Down
23 changes: 15 additions & 8 deletions src/Plugin/resource/DataProvider/DataProviderEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,29 @@ public function view($identifier) {

/**
* {@inheritdoc}
*
* @throws \Exception
* In case there's no content to show, and some exceptions where thrown
* from view(), then the last exception will be thrown.
*/
public function viewMultiple(array $identifiers) {
$return = array();
// If no IDs were requested, we should not throw an exception in case an
// entity is un-accessible by the user.
$rows = array();

foreach ($identifiers as $identifier) {
try {
$row = $this->view($identifier);
$rows[] = $this->view($identifier);
}
catch (InaccessibleRecordException $e) {
$row = NULL;
catch (\Exception $e) {
// Ignore the exceptions in case some content is visible, to allow
// partial success.
}
$return[] = $row;
}
if (!$rows && isset($e)) {
// Re-through the last exception in case no content is visible.
throw $e;
}

return array_values(array_filter($return));
return $rows;
}

/**
Expand Down