public function UserExportPluginBase::profileGetTaxonomyFieldValue in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 8.3 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 8.5 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 8.6 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 8.7 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 8.8 modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 10.3.x modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 10.0.x modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 10.1.x modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
- 10.2.x modules/social_features/social_user_export/src/Plugin/UserExportPluginBase.php \Drupal\social_user_export\Plugin\UserExportPluginBase::profileGetTaxonomyFieldValue()
Returns the values of a taxonomy reference field.
Parameters
string $field_name: The field name to get the value for, should be taxonomy term reference.
\Drupal\profile\Entity\ProfileInterface $user_profile: The profile to get the data for.
Return value
string Returns comma separated string of taxonomy terms of the field.
Overrides UserExportPluginInterface::profileGetTaxonomyFieldValue
4 calls to UserExportPluginBase::profileGetTaxonomyFieldValue()
- OrganizationTag::getValue in modules/
social_features/ social_profile/ modules/ social_profile_organization_tag/ src/ Plugin/ UserExportPlugin/ OrganizationTag.php - Returns the value.
- UserInterests::getValue in modules/
social_features/ social_user_export/ src/ Plugin/ UserExportPlugin/ UserInterests.php - Returns the value.
- UserProfileTag::getValue in modules/
social_features/ social_user_export/ src/ Plugin/ UserExportPlugin/ UserProfileTag.php - Returns the value.
- UserSkills::getValue in modules/
social_features/ social_user_export/ src/ Plugin/ UserExportPlugin/ UserSkills.php - Returns the value.
File
- modules/
social_features/ social_user_export/ src/ Plugin/ UserExportPluginBase.php, line 213
Class
- UserExportPluginBase
- Base class for User export plugin plugins.
Namespace
Drupal\social_user_export\PluginCode
public function profileGetTaxonomyFieldValue($field_name, ProfileInterface $user_profile = NULL) {
if ($user_profile === NULL) {
return '';
}
$concatenated_value = '';
try {
$values = $user_profile
->get($field_name)
->getValue();
if (is_array($values) && !empty($values)) {
$taxonomy_terms = [];
foreach ($values as $x => $value) {
if (isset($value['target_id'])) {
/** @var \Drupal\taxonomy\Entity\Term $term */
$taxonomy_term = Term::load($value['target_id']);
$taxonomy_terms[] = $taxonomy_term
->getName();
}
}
$concatenated_value = implode(', ', $taxonomy_terms);
}
} catch (\Exception $e) {
$concatenated_value = '';
}
return $concatenated_value;
}