protected function Subscriber::getUserSharedFields in Simplenews 8.2
Same name and namespace in other branches
- 8 src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::getUserSharedFields()
- 3.x src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::getUserSharedFields()
Identifies configurable fields shared with a user.
Parameters
\Drupal\user\UserInterface $user: The user to match fields against.
Return value
string[] An indexed array of the names of each field for which there is also a field on the given user with the same name and type.
2 calls to Subscriber::getUserSharedFields()
- Subscriber::copyToAccount in src/
Entity/ Subscriber.php - Copy values to a user account.
- Subscriber::fillFromAccount in src/
Entity/ Subscriber.php - Fill values from a user account.
File
- src/
Entity/ Subscriber.php, line 318
Class
- Subscriber
- Defines the simplenews subscriber entity.
Namespace
Drupal\simplenews\EntityCode
protected function getUserSharedFields(UserInterface $user) {
$field_names = [];
if (\Drupal::config('simplenews.settings')
->get('subscriber.sync_fields')) {
// Find any fields sharing name and type.
foreach ($this
->getFieldDefinitions() as $field_definition) {
/** @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
$field_name = $field_definition
->getName();
$user_field = $user
->getFieldDefinition($field_name);
if ($field_definition
->getTargetBundle() && isset($user_field) && $user_field
->getType() == $field_definition
->getType()) {
$field_names[] = $field_name;
}
}
}
return $field_names;
}