I'm porting a module from Drupal 7 to Drupal 8. In this module's configuration settings I need to get the list of the currently existing field-types.
In Drupal 7, this was achieved using the field_info_field_types()
function.
In Drupal 8 (8.0.0-rc3), I get an error "function does not exist", despite the information stated by a Drupal API Reference Help page, clearly out of date.
Then investigating I found a DrupalContrib page, where the function is declared deprecated, and proposing to now use Drupal::service('plugin.manager.entity.field.field_type')->getDefinitions()
.
But using it fires another error "Unknown service plugin.manager.entity.field.field_type", fortunately associated to the suggestion "Do you mean plugin.manager.field.field_type?"
So I tried using Drupal::service('plugin.manager.field.field_type')->getDefinitions()
and wow: I got the expected array of field-types.
But each array member (one field-type) is now an object (instead of a child array), and the data I'm looking for is nested within protected properties, so I can't access them.
At this stage, I'm stuck. I considered it might exist some class I could expand to navigate through these data, but with no luck: I notably couldn't even figure out which is the component in Drupal 8 where field-types definitions is centralized.