public function BakeryUserHooks::presave in Bakery Single Sign-On System 8.2
File
- src/BakeryUserHooks.php, line 64
Class
- BakeryUserHooks
Namespace
Drupal\bakery
Code
public function presave(UserInterface $account) {
if ($this
->isMain() && $account
->id() > 1 && isset($account->original)) {
foreach ($this->config
->get('bakery_supported_fields') as $type => $enabled) {
$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:
$o_v = $original
->get($type)
->getValue();
$n_v = $account
->get($type)
->getValue();
break;
}
if ($o_v != $n_v) {
$_SESSION['bakery'][$type] = $n_v;
}
}
}
}
}