How to translate Drupal API to functioning code?

by liquidcms   Last Updated January 12, 2018 06:07 AM

I was searching for how to find field info and came across this post: getFieldDefinitions on Drupal 8 (why all these deprecated functions on DP8?).

Which gives an answer of:

Drupal::service('entity_field.manager')->getFieldDefinitions(xxx, xxx);

but my question is generically how would a developer tell from this page on the Drupal API docs: that this needs to be called as a service and that the service is entity_field.manager?

.. and, why does simply:

\Drupal\EntityFieldManager::getFieldDefinitions($etid, $bundle)

not work?

Tags : fields

Related Questions

How would I create conditional fields on install?

Updated October 13, 2016 09:03 AM