public function Subscriber::getUser in Simplenews 8.2
Same name and namespace in other branches
- 8 src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::getUser()
- 3.x src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::getUser()
Returns corresponding User object, if any.
Return value
\Drupal\user\UserInterface|null The corresponding User object, or NULL if the subscriber is not synced with a user.
Overrides SubscriberInterface::getUser
2 calls to Subscriber::getUser()
- Subscriber::postCreate in src/
Entity/ Subscriber.php - Acts on a created entity before hooks are invoked.
- 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 111
Class
- Subscriber
- Defines the simplenews subscriber entity.
Namespace
Drupal\simplenews\EntityCode
public function getUser() {
$uid = $this
->getUserId();
if ($uid && ($user = User::load($uid))) {
return $user;
}
elseif ($mail = $this
->getMail()) {
return user_load_by_mail($mail) ?: NULL;
}
else {
return NULL;
}
}