Problem
#2329937: Allow definition objects to provide options is going to move providing options from field item classes to field definitions.
This API change is required to prepare making $entity optional for fetching the options of a field, i.e. you'll be able to fetch the options of the FieldStorageDefinition instead. Right now, $entity is still required, but making the required entity parameter optional later on won't be an API change.
Proposed resolution
Make field definitions as the primary API to fetch options providers now, and make it controllable by field definitions in [#2329937 later.
Remaining tasks
Do it.
User interface changes
-
API changes
To fetch e.g. the options of a list field formatters will have to do:
$field_definition->getOptionsProvider($property_name, $entity)->getAvailableOptions();
instead of the previous
$field_item->getAvailableOptions();
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | d8_options.patch | 7.84 KB | fago |
| #6 | d8_options.interdiff.txt | 886 bytes | fago |
| #2 | d8_options.patch | 7.87 KB | fago |
Comments
Comment #1
fagoComment #2
fagoPatch attached.
Comment #4
yched commentedFieldStorageConfig::getOptionsProvider() is right,
BaseFieldDefinition::getOptionsProvider() is wrong :-)
It's the $item that can be instanceof OptionsProviderInterface, not the $item_list
Comment #5
fagoOps, forgot to update the other implementation. Thanks for catching!
Comment #6
fagoComment #7
yched commentedGood if green :-)
Comment #8
fagoComment #9
webchickCommitted and pushed to 8.x. Thanks!