public function Subscriber::copyToAccount in Simplenews 3.x
Same name and namespace in other branches
- 8.2 src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::copyToAccount()
Copy values to a user account.
Parameters
\Drupal\Core\Session\AccountInterface $account: The account to copy to.
Overrides SubscriberInterface::copyToAccount
1 call to Subscriber::copyToAccount()
- Subscriber::postSave in src/
Entity/ Subscriber.php - Acts on a saved entity before the insert or update hook is invoked.
File
- src/
Entity/ Subscriber.php, line 164
Class
- Subscriber
- Defines the simplenews subscriber entity.
Namespace
Drupal\simplenews\EntityCode
public function copyToAccount(AccountInterface $account) {
// Copy values for shared fields to existing user.
if (!static::$syncing && ($fields = $this
->getUserSharedFields($account))) {
static::$syncing = TRUE;
foreach ($fields as $field_name) {
$account
->set($field_name, $this
->get($field_name)
->getValue());
}
if (!$account
->isNew()) {
$account
->save();
}
static::$syncing = FALSE;
}
}