I needed the field list related a vocabulary item.I was able to list the fields related to a content type by using like this:
But I can't find a way for the vocabulary items.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
\Drupal::entityManager() is deprecated, instead you should use
\Drupal::entityTypeManager. From the docs:
Deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager() instead in most cases. If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service.
With all of this said, you can use the same method to get taxonomy term fields as any other bundle. As documented in this related answer:
$entity_type_id = 'taxonomy_term'; $bundle = 'article_tags'; // Load the field definitions for any bundle. $my_bundle_fields = \Drupal::service('entity_field.manager') ->getFieldDefinitions($entity_type_id, $bundle);