Compare commits
2 commits
951c6acfcb
...
d8c47aebb0
Author | SHA1 | Date | |
---|---|---|---|
|
d8c47aebb0 | ||
|
4f1deefa09 |
1 changed files with 10 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace EesyPHP\Auth;
|
namespace EesyPHP\Auth;
|
||||||
|
|
||||||
|
use EesyPHP\Hook;
|
||||||
use EesyPHP\Log;
|
use EesyPHP\Log;
|
||||||
use function EesyPHP\ensure_is_array;
|
use function EesyPHP\ensure_is_array;
|
||||||
use function EesyPHP\vardump;
|
use function EesyPHP\vardump;
|
||||||
|
@ -135,17 +136,24 @@ class User {
|
||||||
*/
|
*/
|
||||||
public function save() {
|
public function save() {
|
||||||
if (!isset($this -> original_user)) {
|
if (!isset($this -> original_user)) {
|
||||||
Log::debug("%s->save(): no change to save", $this);
|
Log::debug("%s->save(): original_user not set, no change to save.", $this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$changes = [];
|
$changes = [];
|
||||||
foreach ($this->info as $attr => $value)
|
foreach ($this->info as $attr => $value)
|
||||||
if ($this->original_user->$attr != $value)
|
if ($this->original_user->$attr != $value)
|
||||||
$changes[$attr] = $value;
|
$changes[$attr] = $value;
|
||||||
return call_user_func(
|
if (!$changes) {
|
||||||
|
Log::debug("%s->save(): no info updated, no change to save", $this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$result = call_user_func(
|
||||||
array($this -> backend, 'update_user'),
|
array($this -> backend, 'update_user'),
|
||||||
$this -> original_user, $changes, true
|
$this -> original_user, $changes, true
|
||||||
);
|
);
|
||||||
|
if ($result)
|
||||||
|
Hook::trigger("user_updated", ["user" => $this, "changes" => $changes]);
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue