public function RestrictedNameProcessor::addFieldValues in Open Social 10.1.x
Same name and namespace in other branches
- 8.9 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::addFieldValues()
- 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::addFieldValues()
- 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::addFieldValues()
- 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::addFieldValues()
- 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::addFieldValues()
- 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::addFieldValues()
File
- modules/
social_features/ social_profile/ modules/ social_profile_privacy/ src/ Plugin/ search_api/ processor/ RestrictedNameProcessor.php, line 88
Class
- RestrictedNameProcessor
- The RestrictedNameProcessor adds the restricted name to search indexes.
Namespace
Drupal\social_profile_privacy\Plugin\search_api\processorCode
public function addFieldValues(ItemInterface $item) {
$restricted_name = NULL;
$nickname = $this
->getFirstItemField($item, 'field_profile_nick_name');
// If the user specified a nickname then we will default to using it as
// restricted name.
if ($nickname !== '') {
$restricted_name = $nickname;
}
else {
$first_name = $this
->getFirstItemField($item, 'field_profile_first_name');
$last_name = $this
->getFirstItemField($item, 'field_profile_last_name');
$full_name = trim($first_name . ' ' . $last_name);
if ($full_name !== '') {
$restricted_name = $full_name;
}
}
// If we have a restricted name we add it as a value for all of our
// restricted name fields.
if ($restricted_name) {
$fields = $this
->getFieldsHelper()
->filterForPropertyPath($item
->getFields(), $item
->getDatasourceId(), 'social_profile_privacy_restricted_name');
foreach ($fields as $field) {
$field
->addValue($restricted_name);
}
}
}