You are here

public function SearchApiEntityField::defineOptions in Search API 8

Defines the options used by this plugin.

Return value

array Returns the options of this handler/plugin.

Overrides SearchApiFieldTrait::defineOptions

See also

\Drupal\views\Plugin\views\PluginBase::defineOptions()

File

src/Plugin/views/field/SearchApiEntityField.php, line 98

Class

SearchApiEntityField
Displays entity field data.

Namespace

Drupal\search_api\Plugin\views\field

Code

public function defineOptions() {
  $options = parent::defineOptions();

  // Gather the fallback handler's options, but exclude those just inherited
  // from the field plugin base (since they would otherwise be duplicated).
  // To find out which options should be excluded, we take the $options keys
  // from the parent and remove the keys that come directly from the parent.
  $fallback_options = [];
  $fallback_define_options = [
    $this->fallbackHandler,
    'defineOptions',
  ];
  if (is_callable($fallback_define_options)) {
    $fallback_options = call_user_func($fallback_define_options);
    $parent_keys = $this
      ->getParentOptionKeys();
    $remove_from_fallback = array_diff_key($options, array_flip($parent_keys));
    $fallback_options = array_diff_key($fallback_options, $remove_from_fallback);
  }
  $options['field_rendering'] = [
    'default' => TRUE,
  ];
  $options['fallback_handler'] = [
    'default' => $this->fallbackHandler
      ->getPluginId(),
  ];
  $options['fallback_options'] = [
    'contains' => $fallback_options,
  ];
  return $options;
}