Add 'oldUsername' to User\Event\Renamed (#1563)

This commit is contained in:
David Sevilla Martín 2018-09-03 16:42:30 -04:00 committed by Franz Liedke
parent e03cc3d9c9
commit 8e331d5817
2 changed files with 10 additions and 2 deletions

View File

@ -20,6 +20,11 @@ class Renamed
*/ */
public $user; public $user;
/**
* @var string
*/
public $oldUsername;
/** /**
* @var User * @var User
*/ */
@ -27,11 +32,13 @@ class Renamed
/** /**
* @param User $user * @param User $user
* @param string $oldUsername
* @param User $actor * @param User $actor
*/ */
public function __construct(User $user, User $actor = null) public function __construct(User $user, string $oldUsername, User $actor = null)
{ {
$this->user = $user; $this->user = $user;
$this->oldUsername = $oldUsername;
$this->actor = $actor; $this->actor = $actor;
} }
} }

View File

@ -198,9 +198,10 @@ class User extends AbstractModel
public function rename($username) public function rename($username)
{ {
if ($username !== $this->username) { if ($username !== $this->username) {
$oldUsername = $this->username;
$this->username = $username; $this->username = $username;
$this->raise(new Renamed($this)); $this->raise(new Renamed($this, $oldUsername));
} }
return $this; return $this;