public function BakeryUserHooks::presave in Bakery Single Sign-On System 8.2
File
- src/
BakeryUserHooks.php, line 64
Class
Namespace
Drupal\bakeryCode
public function presave(UserInterface $account) {
// If this is the main site, its not the admin user, and there's updated
// data, then we want to possibly send some updates.
if ($this
->isMain() && $account
->id() > 1 && isset($account->original)) {
// We store email/name if they changed. We want to wait with doing
// anything else until the changes are saved locally.
foreach ($this->config
->get('bakery_supported_fields') as $type => $enabled) {
/** @var \Drupal\user\UserInterface $original */
$original = $account->original;
if ($enabled) {
switch ($type) {
case 'name':
$o_v = $original
->getAccountName();
$n_v = $account
->getAccountName();
break;
case 'mail':
$o_v = $original
->getEmail();
$n_v = $account
->getEmail();
break;
case 'status':
$o_v = $original
->isActive();
$n_v = $account
->isActive();
break;
default:
// does this work?
$o_v = $original
->get($type)
->getValue();
$n_v = $account
->get($type)
->getValue();
break;
}
if ($o_v != $n_v) {
$_SESSION['bakery'][$type] = $n_v;
}
}
}
}
}