You are here

protected function DropdownWidgetType::getOptions in Open Social 8.9

Same name and namespace in other branches
  1. 8 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  2. 8.2 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  3. 8.3 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  4. 8.4 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  5. 8.5 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  6. 8.6 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  7. 8.7 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  8. 8.8 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  9. 10.3.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  10. 10.0.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  11. 10.1.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()
  12. 10.2.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getOptions()

Returns the array of options for the widget.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity for which to return options.

Return value

array The array of options for the widget.

2 calls to DropdownWidgetType::getOptions()
DropdownWidgetType::formElement in modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php
Returns the form for a single field widget.
DropdownWidgetType::getSelectedOptions in modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php
Determines selected options from the incoming field values.

File

modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php, line 100

Class

DropdownWidgetType
Plugin implementation of the 'dropdown_widget_type' widget.

Namespace

Drupal\dropdown\Plugin\Field\FieldWidget

Code

protected function getOptions(FieldableEntityInterface $entity) {
  if (!isset($this->options)) {

    // Limit the settable options for the current user account.
    $options = $this->fieldDefinition
      ->getFieldStorageDefinition()
      ->getSetting('allowed_values');
    $module_handler = \Drupal::moduleHandler();
    $context = [
      'fieldDefinition' => $this->fieldDefinition,
      'entity' => $entity,
    ];
    $module_handler
      ->alter('dropdown_list', $options, $context);
    array_walk_recursive($options, [
      $this,
      'sanitizeLabel',
    ]);
    $this->options = $options;
  }
  return $this->options;
}