public function SocialProfileFieldsHelper::getProfileFields in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 8.3 modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 8.4 modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 8.5 modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 8.6 modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 8.7 modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 10.3.x modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 10.0.x modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 10.1.x modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
- 10.2.x modules/social_features/social_profile/modules/social_profile_fields/src/SocialProfileFieldsHelper.php \Drupal\social_profile_fields\SocialProfileFieldsHelper::getProfileFields()
Functions fetches profile fields from a profile type.
Parameters
string $profile_type_id: The profile bundle.
Return value
array An array of fields.
File
- modules/
social_features/ social_profile/ modules/ social_profile_fields/ src/ SocialProfileFieldsHelper.php, line 49
Class
- SocialProfileFieldsHelper
- Class SocialProfileFieldsHelper.
Namespace
Drupal\social_profile_fieldsCode
public function getProfileFields($profile_type_id) {
$fields = [];
// Use storage to get only the profile fields of the current bundle type.
try {
$profile_fields = $this->entityTypeManager
->getStorage('field_config')
->loadByProperties([
'entity_type' => 'profile',
'bundle' => $profile_type_id,
]);
} catch (\Exception $e) {
return $fields;
}
// Loop through the fields and return the necessary values.
/** @var \Drupal\Core\Field\FieldConfigInterface $profile_field */
foreach ($profile_fields as $profile_field) {
// Rewrite the ID a bit, since otherwise config thinks it's an array.
$id = str_replace('.', '_', $profile_field
->id());
// Build the array.
$fields[$id] = [
'id' => $id,
'name' => $profile_field
->getName(),
'label' => $profile_field
->getLabel(),
];
}
// Return the array of fields.
return $fields;
}