public function profileGetTaxonomyFieldValue($field_name, ProfileInterface $user_profile = NULL) {
    if ($user_profile === NULL) {
      return '';
    }

    $names = array_map(
      function (TermInterface $taxonomy_term) {
        return $taxonomy_term->getName();
      },
      $user_profile->get($field_name)->referencedEntities()
    );

    return implode(', ', $names);
  }
public function profileGetTaxonomyFieldValue($field_name, ProfileInterface $user_profile = NULL) {
    if ($user_profile === NULL) {
      return '';
    }

    $names = array_map(
      function (TermInterface $taxonomy_term) {
        return $taxonomy_term->getName();
      },
      $user_profile->get($field_name)->referencedEntities()
    );

    return implode(', ', $names);
  }
public function profileGetTaxonomyFieldValue ( $ field_name , ProfileInterface $ user_profile = NULL ) { if ( $ user_profile === NULL ) { return '' ; } $ names = array_map ( function ( TermInterface $ taxonomy_term ) { return $ taxonomy_term -> getName ( ) ; } , $ user_profile -> get ( $ field_name ) -> referencedEntities ( ) ) ; return implode ( ', ' , $ names ) ; }
Returns the values of a taxonomy reference field.

@param string $field_name
The field name to get the value for, should be taxonomy term reference.
@param \Drupal\profile\Entity\ProfileInterface $user_profile
The profile to get the data for.

@return string
Returns comma separated string of taxonomy terms of the field.
Returns the values of a taxonomy reference field .