mirror of
https://github.com/flarum/framework.git
synced 2025-03-30 03:15:13 +08:00
Add 'oldUsername' to User\Event\Renamed (#1563)
This commit is contained in:
parent
5a9b47cdf7
commit
43fc2c0952
@ -20,6 +20,11 @@ class Renamed
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $oldUsername;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
@ -27,11 +32,13 @@ class Renamed
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $oldUsername
|
||||
* @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->oldUsername = $oldUsername;
|
||||
$this->actor = $actor;
|
||||
}
|
||||
}
|
||||
|
@ -198,9 +198,10 @@ class User extends AbstractModel
|
||||
public function rename($username)
|
||||
{
|
||||
if ($username !== $this->username) {
|
||||
$oldUsername = $this->username;
|
||||
$this->username = $username;
|
||||
|
||||
$this->raise(new Renamed($this));
|
||||
$this->raise(new Renamed($this, $oldUsername));
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user