protected function RestrictedNameProcessor::getFirstItemField in Open Social 8.9
Same name and namespace in other branches
- 8.7 modules/social_features/social_profile/modules/social_profile_privacy/src/Plugin/search_api/processor/RestrictedNameProcessor.php \Drupal\social_profile_privacy\Plugin\search_api\processor\RestrictedNameProcessor::getFirstItemField()
- 8.8 modules/social_features/social_profile/modules/social_profile_privacy/src/Plugin/search_api/processor/RestrictedNameProcessor.php \Drupal\social_profile_privacy\Plugin\search_api\processor\RestrictedNameProcessor::getFirstItemField()
- 10.3.x modules/social_features/social_profile/modules/social_profile_privacy/src/Plugin/search_api/processor/RestrictedNameProcessor.php \Drupal\social_profile_privacy\Plugin\search_api\processor\RestrictedNameProcessor::getFirstItemField()
- 10.0.x modules/social_features/social_profile/modules/social_profile_privacy/src/Plugin/search_api/processor/RestrictedNameProcessor.php \Drupal\social_profile_privacy\Plugin\search_api\processor\RestrictedNameProcessor::getFirstItemField()
- 10.1.x modules/social_features/social_profile/modules/social_profile_privacy/src/Plugin/search_api/processor/RestrictedNameProcessor.php \Drupal\social_profile_privacy\Plugin\search_api\processor\RestrictedNameProcessor::getFirstItemField()
- 10.2.x modules/social_features/social_profile/modules/social_profile_privacy/src/Plugin/search_api/processor/RestrictedNameProcessor.php \Drupal\social_profile_privacy\Plugin\search_api\processor\RestrictedNameProcessor::getFirstItemField()
Fetches the first value of a field for an item.
Parameters
\Drupal\search_api\Item\ItemInterface $item: The item that the field belongs to.
string $field_name: The name of the field.
Return value
string The first value of the item or an empty string if no value could be found.
1 call to RestrictedNameProcessor::getFirstItemField()
- RestrictedNameProcessor::addFieldValues in modules/
social_features/ social_profile/ modules/ social_profile_privacy/ src/ Plugin/ search_api/ processor/ RestrictedNameProcessor.php - Adds the values of properties defined by this processor to the item.
File
- modules/
social_features/ social_profile/ modules/ social_profile_privacy/ src/ Plugin/ search_api/ processor/ RestrictedNameProcessor.php, line 179
Class
- RestrictedNameProcessor
- The RestrictedNameProcessor adds the restricted name to search indexes.
Namespace
Drupal\social_profile_privacy\Plugin\search_api\processorCode
protected function getFirstItemField(ItemInterface $item, string $field_name) : string {
$field = $item
->getField($field_name);
// If the field doesn't exist we default to an empty string.
if (!$field) {
return '';
}
$field_values = $field
->getValues();
// If the field has no values then we convert it to an empty string.
if (empty($field_values)) {
return '';
}
return reset($field_values);
}