mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 23:23:52 +08:00
Add 'oldUsername' to User\Event\Renamed (#1563)
This commit is contained in:
parent
e03cc3d9c9
commit
8e331d5817
|
@ -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…
Reference in New Issue
Block a user