protected function OtherView::getOtherViewsResults in OtherView Filter 8
Return requested views results.
Parameters
array $views: List of views and displays.
Return value
array Requested views results.
1 call to OtherView::getOtherViewsResults()
- OtherView::opSimple in src/
Plugin/ views/ filter/ OtherView.php
File
- src/
Plugin/ views/ filter/ OtherView.php, line 173
Class
- OtherView
- Filter content by other view results set.
Namespace
Drupal\other_view_filter\Plugin\views\filterCode
protected function getOtherViewsResults(array $views) {
$results = [];
if (empty($views)) {
return $results;
}
foreach ($views as $view_display) {
list($name, $display) = explode(':', $view_display, 2);
// Get the results of the specified view/display combo.
if ($name && $display) {
$view = $this->viewStorage
->load($name);
if (!$view instanceof ViewEntityInterface) {
continue;
}
$view = $view
->getExecutable();
if (!$view instanceof ViewExecutable || !$view
->access($display)) {
continue;
}
if ($this->options['inherit_contextual_filters'] && !empty($this->defaultArgs)) {
$view
->setArguments($this->defaultArgs);
}
$view
->setDisplay($display);
$view
->preExecute();
$view
->execute();
if (empty($view->result)) {
continue;
}
foreach ($view->result as $row) {
if (isset($row->{$this->realField})) {
$results[$row->{$this->realField}] = $row->{$this->realField};
}
}
}
}
return $results ? array_values($results) : [];
}