Spin off from #1988612: Apply formatters and widgets to rendered entity base fields, starting with node.created
Copied from over there:
Once #1969728: Implement Field API "field types" as TypedData Plugins is done, widgets and formatters are going to be the only thing that work with the old style $items arrays for field values.
Aside from API consistency, avoiding that conversion / format change would probably be a performance win - especially since :
- all those methods are called through a single set of helpers : field_invoke_method() / field_invoke_method_multiple() (they currently work only on Field API fields, that would be changed by making the EntityDisplay responsible for rendering)
- some of those methods (Widget::extractFormValues() & Formatter::prepareView()) do some writing to the $items, and thus the invoke helpers currently do the job of assigning the array values back into the FieldItem objects - for *all* methods, since they don't carry any knowledge of which methods write to the values or not.
This dance between "new (FieldItem objects) native format for field values" and "old (array) format for field values handed to widgets / formatters" is very far from ideal performance wise, and it possibly only works right now because there's an EntityBC layer that we switch the $entity to before calling the field_invoke_method() / field_invoke_method_multiple() helpers that bridge to the widgets & formatters. But that BC layer is intended to go away at some point...
It shouldn't be a very complex task in itself, but doing it on all formatters and widgets affects a lot of code...