-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove IUserGetter interface, use UserEventInterface
IUserGetter was deprecated in version 2.3 (Feb 2023) https://github.com/remp2020/crm-users-module/releases/tag/2.3.0 Use UserEventInterface instead (method `getUserId(): int` replaced by `getUser(): ActiveRow`. remp/crm#3313
- Loading branch information
Showing
7 changed files
with
41 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Crm\UsersModule\Events; | ||
|
||
use Crm\UsersModule\Models\User\IUserGetter; | ||
use Crm\UsersModule\Models\User\UserData; | ||
use League\Event\AbstractListener; | ||
use League\Event\EventInterface; | ||
|
||
class RefreshUserDataTokenHandler extends AbstractListener | ||
{ | ||
private $userData; | ||
|
||
public function __construct(UserData $userData) | ||
{ | ||
$this->userData = $userData; | ||
public function __construct( | ||
private UserData $userData, | ||
) { | ||
} | ||
|
||
public function handle(EventInterface $event) | ||
{ | ||
if (!($event instanceof IUserGetter)) { | ||
throw new \Exception('cannot handle event, invalid instance received: ' . gettype($event)); | ||
if (!($event instanceof UserEventInterface)) { | ||
throw new \Exception('Invalid type of event received, `UserEventInterface` expected, but got ' . gettype($event)); | ||
} | ||
|
||
$userId = $event->getUserId(); | ||
$this->userData->refreshUserTokens($userId); | ||
$this->userData->refreshUserTokens($event->getUser()->id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Crm\UsersModule\Events; | ||
|
||
use Crm\UsersModule\Models\User\IUserGetter; | ||
use League\Event\AbstractEvent; | ||
use Nette\Database\Table\ActiveRow; | ||
|
||
class UserUpdatedEvent extends AbstractEvent implements IUserGetter | ||
class UserUpdatedEvent extends AbstractEvent implements UserEventInterface | ||
{ | ||
private $user; | ||
|
||
public function __construct($user) | ||
{ | ||
$this->user = $user; | ||
public function __construct( | ||
private ActiveRow $user, | ||
) { | ||
} | ||
|
||
public function getUser() | ||
public function getUser(): ActiveRow | ||
{ | ||
return $this->user; | ||
} | ||
|
||
public function getUserId(): int | ||
{ | ||
return $this->user->id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters