mirror of
https://github.com/flarum/framework.git
synced 2024-12-04 00:03:37 +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;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user