Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294726

Brush up MetadataGeneratorInterface::generateField()

$
0
0

With the Field API improvements that went in the past weeks / months, looks like MetadataGeneratorInterface::generateField() could be refactored a bit:

- method name is weird, this is not generating a field :-)

- signature is generateField(EntityInterface $entity, FieldDefinitionInterface $field_definition, $langcode, $view_mode),
and part of the job of the method is to work on $items = $entity->getTranslation($langcode)->get($field_definition->getFieldName())
Typically, those kind of functions have switched to receiving $items directly, letting the caller resolve entity translation.
So this could be just generateField(FieldItemListInterface $items, $view_mode)

- editorSelector->getEditor($formatter_id, $field_definition, $items) should receive $items as the FieldItemListInterface object, instead of one that has been cast to an array by ->getValue()
Could then just be getEditor($formatter_id, FieldItemListInterface $items) - and then switching the order of arguments might be more consistent with what the rest of core does ($items is typically the primary business logic parameter)


Viewing all articles
Browse latest Browse all 294726

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>