public function SocialProfileNameService::needToUpdateProfileName in Open Social 10.2.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_profile/src/SocialProfileNameService.php \Drupal\social_profile\SocialProfileNameService::needToUpdateProfileName()
Whether or not need to update the Profile name.
Parameters
\Drupal\profile\Entity\ProfileInterface $profile: The profile.
Return value
bool Whether or not need to update the Profile name.
File
- modules/
social_features/ social_profile/ src/ SocialProfileNameService.php, line 55
Class
- SocialProfileNameService
- Provide a service for Profile name.
Namespace
Drupal\social_profileCode
public function needToUpdateProfileName(ProfileInterface $profile) : bool {
// Do nothing if no profile.
if ($profile == NULL) {
return FALSE;
}
$profile_name_fields = SocialProfileNameService::getProfileNameFields();
/** @var \Drupal\Core\Entity\ContentEntityBase $original */
$original = $profile->original ?? NULL;
// If it is new Profile and we have no origin then we need set generated
// Profile name field.
if ($original == NULL) {
return TRUE;
}
// If some of profile name fields changed we need update Profile name field.
foreach ($profile_name_fields as $profile_name_field) {
if (!$profile
->get($profile_name_field)
->equals($original
->get($profile_name_field))) {
return TRUE;
}
}
return FALSE;
}