You are here

public function ViewfieldItem::getViewOptions in Viewfield 8.3

Get an options array of views.

Parameters

bool $filter: (optional) Flag to filter the output using the 'allowed_views' setting.

Return value

array The array of options.

1 call to ViewfieldItem::getViewOptions()
ViewfieldItem::fieldSettingsForm in src/Plugin/Field/FieldType/ViewfieldItem.php
Returns a form for the field-level settings.

File

src/Plugin/Field/FieldType/ViewfieldItem.php, line 181

Class

ViewfieldItem
Plugin implementation of the 'viewfield' field type.

Namespace

Drupal\viewfield\Plugin\Field\FieldType

Code

public function getViewOptions($filter = TRUE) {
  $views_options = [];
  $allowed_views = $filter ? array_filter($this
    ->getSetting('allowed_views')) : [];
  foreach (Views::getEnabledViews() as $key => $view) {
    if (empty($allowed_views) || isset($allowed_views[$key])) {
      $views_options[$key] = FieldFilteredMarkup::create($view
        ->get('label'));
    }
  }
  natcasesort($views_options);
  return $views_options;
}