function BaseFieldDefinition::getOptionsProvider
Same name in other branches
- 9 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::getOptionsProvider()
- 8.9.x core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::getOptionsProvider()
- 10 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::getOptionsProvider()
Overrides FieldStorageDefinitionInterface::getOptionsProvider
File
-
core/
lib/ Drupal/ Core/ Field/ BaseFieldDefinition.php, line 560
Class
- BaseFieldDefinition
- A class for defining entity fields.
Namespace
Drupal\Core\FieldCode
public function getOptionsProvider($property_name, FieldableEntityInterface $entity) {
// If the field item class implements the interface, create an orphaned
// runtime item object, so that it can be used as the options provider
// without modifying the entity being worked on.
if (is_subclass_of($this->getItemDefinition()
->getClass(), OptionsProviderInterface::class)) {
$items = $entity->get($this->getName());
return \Drupal::service('plugin.manager.field.field_type')->createFieldItem($items, 0);
}
// @todo Allow setting custom options provider.
// https://www.drupal.org/node/2002138
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.