You are here

public function EntityDisplayTrait::getWidgetSettings in CCK Select Other 8

Get the select other widget settings from the form display.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $definition: The field definition to extract the widget from.

Return value

array An array of settings.

1 call to EntityDisplayTrait::getWidgetSettings()
SelectOtherFilter::init in src/Plugin/views/filter/SelectOtherFilter.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().

File

src/EntityDisplayTrait.php, line 81

Class

EntityDisplayTrait
Provides methods for dealing with entity displays.

Namespace

Drupal\cck_select_other

Code

public function getWidgetSettings(FieldDefinitionInterface $definition) {
  $displays = $this
    ->getFormDisplays($definition, $this
    ->getEntityTypeManager());
  $field_name = $definition
    ->getName();
  $settings = [];
  $widget = array_reduce($displays, function (&$result, $display) use ($field_name) {

    /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display */
    if (!$result) {
      $widget = $display
        ->getRenderer($field_name);
      if ($widget && $widget
        ->getPluginId() === 'cck_select_other') {
        $result = $widget;
      }
    }
    return $result;
  }, FALSE);
  if ($widget) {
    $settings = $widget
      ->getSettings();
  }
  return $settings;
}