You are here

protected function ViewsReferenceTrait::getViewNames in Views Reference Field 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/ViewsReferenceTrait.php \Drupal\viewsreference\Plugin\Field\FieldWidget\ViewsReferenceTrait::getViewNames()

Helper to convert view array of machine names to label names.

1 call to ViewsReferenceTrait::getViewNames()
ViewsReferenceSelectWidget::formElement in src/Plugin/Field/FieldWidget/ViewsReferenceSelectWidget.php
Returns the form for a single field widget.

File

src/Plugin/Field/FieldWidget/ViewsReferenceTrait.php, line 222

Class

ViewsReferenceTrait
Trait for shared code in Viewsreference Field Widgets.

Namespace

Drupal\viewsreference\Plugin\Field\FieldWidget

Code

protected function getViewNames($views_array) {
  $views_list = [];
  foreach ($views_array as $key => $value) {
    $view = Views::getView($key);
    if (isset($view)) {
      $views_list[$view->storage
        ->id()] = $view->storage
        ->label();
    }
  }
  return $views_list;
}