protected function ViewsReferenceTrait::getViewDisplayIds in Views Reference Field 8
Helper to get display ids for a particular View.
2 calls to ViewsReferenceTrait::getViewDisplayIds()
- ViewsReferenceTrait::fieldElement in src/
Plugin/ Field/ FieldWidget/ ViewsReferenceTrait.php - Build the field element.
- ViewsReferenceTrait::getDisplayIds in src/
Plugin/ Field/ FieldWidget/ ViewsReferenceTrait.php - AJAX function to get display IDs for a particular View.
File
- src/
Plugin/ Field/ FieldWidget/ ViewsReferenceTrait.php, line 205
Class
- ViewsReferenceTrait
- Trait for shared code in Viewsreference Field Widgets.
Namespace
Drupal\viewsreference\Plugin\Field\FieldWidgetCode
protected function getViewDisplayIds($view_id) {
$options = [];
$view_plugins = array_diff($this
->getFieldSetting('plugin_types'), [
"0",
]);
if ($view = \Drupal::service('entity_type.manager')
->getStorage('view')
->load($view_id)) {
foreach ($view
->get('display') as $display) {
if (in_array($display['display_plugin'], $view_plugins)) {
$options[$display['id']] = $display['display_title'];
}
}
}
return $options;
}