diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-13 19:38:22 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-02-14 10:50:37 +0300 |
commit | 57d04a562e4c9b0864c23068650d1939981960b4 (patch) | |
tree | eeb6395849d7ea22d3397da2e478c8792483876b /lib/PublicShareAuth/Listener.php | |
parent | d702aa08415ff8c664b35b1767a55ebad9ddaeba (diff) |
Do not load unnecessary classes in Application
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/PublicShareAuth/Listener.php')
-rw-r--r-- | lib/PublicShareAuth/Listener.php | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/lib/PublicShareAuth/Listener.php b/lib/PublicShareAuth/Listener.php index 0e5fd6c97..94999497a 100644 --- a/lib/PublicShareAuth/Listener.php +++ b/lib/PublicShareAuth/Listener.php @@ -44,37 +44,30 @@ use Symfony\Component\EventDispatcher\GenericEvent; */ class Listener { - /** @var EventDispatcherInterface */ - protected $dispatcher; - - public function __construct(EventDispatcherInterface $dispatcher) { - $this->dispatcher = $dispatcher; - } - - public function register(): void { + public static function register(EventDispatcherInterface $dispatcher): void { $listener = function(GenericEvent $event) { /** @var Room $room */ $room = $event->getSubject(); - $this->preventExtraUsersFromJoining($room, $event->getArgument('userId')); + self::preventExtraUsersFromJoining($room, $event->getArgument('userId')); }; - $this->dispatcher->addListener(Room::class . '::preJoinRoom', $listener); + $dispatcher->addListener(Room::class . '::preJoinRoom', $listener); $listener = function(GenericEvent $event) { /** @var Room $room */ $room = $event->getSubject(); - $this->preventExtraGuestsFromJoining($room); + self::preventExtraGuestsFromJoining($room); }; - $this->dispatcher->addListener(Room::class . '::preJoinRoomGuest', $listener); + $dispatcher->addListener(Room::class . '::preJoinRoomGuest', $listener); $listener = function(GenericEvent $event) { /** @var Room $room */ $room = $event->getSubject(); - $this->destroyRoomOnParticipantLeave($room); + self::destroyRoomOnParticipantLeave($room); }; - $this->dispatcher->addListener(Room::class . '::postRemoveUser', $listener); - $this->dispatcher->addListener(Room::class . '::postRemoveBySession', $listener); - $this->dispatcher->addListener(Room::class . '::postUserDisconnectRoom', $listener); - $this->dispatcher->addListener(Room::class . '::postCleanGuests', $listener); + $dispatcher->addListener(Room::class . '::postRemoveUser', $listener); + $dispatcher->addListener(Room::class . '::postRemoveBySession', $listener); + $dispatcher->addListener(Room::class . '::postUserDisconnectRoom', $listener); + $dispatcher->addListener(Room::class . '::postCleanGuests', $listener); } /** @@ -87,7 +80,7 @@ class Listener { * @param string $userId * @throws \OverflowException */ - public function preventExtraUsersFromJoining(Room $room, string $userId): void { + public static function preventExtraUsersFromJoining(Room $room, string $userId): void { if ($room->getObjectType() !== 'share:password') { return; } @@ -114,7 +107,7 @@ class Listener { * @param Room $room * @throws \OverflowException */ - public function preventExtraGuestsFromJoining(Room $room): void { + public static function preventExtraGuestsFromJoining(Room $room): void { if ($room->getObjectType() !== 'share:password') { return; } @@ -134,7 +127,7 @@ class Listener { * * @param Room $room */ - public function destroyRoomOnParticipantLeave(Room $room): void { + public static function destroyRoomOnParticipantLeave(Room $room): void { if ($room->getObjectType() !== 'share:password') { return; } |