By claudiu.cristea on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
11.4.x
Introduced in version:
11.4.0
Issue links:
Description:
The options_allowed_values() procedural function is deprecated and its logic is moved to a new service Drupal\options\OptionsAllowedValuesInterface
Before
$field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'recipe');
if (isset(field_definitions['fruit'])) {
$field_definition = field_definitions['fruit'];
$field_storage_definition = $field_definition->getFieldStorageDefinition();
$allowed_options = options_allowed_values($field_storage_definition);
}
After
use Drupal\options\OptionsAllowedValuesInterface;
$field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'recipe');
if (isset(field_definitions['fruit'])) {
$field_definition = field_definitions['fruit'];
$field_storage_definition = $field_definition->getFieldStorageDefinition();
// Inject the service when possible.
$allowed_options = \Drupal::service(OptionsAllowedValuesInterface::class)
->getAllowedValues($field_storage_definition);
}
Impacts:
Module developers
Site templates, recipes and distribution developers