diff options
author | Joas Schilling <coding@schilljs.com> | 2017-11-10 11:23:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-10 11:23:28 +0100 |
commit | 969bbf166f5e35b7bdf5cfceda37b5b7e2f48f8d (patch) | |
tree | 340ff0ceb7a96f86cba4945523328acd707e81a2 | |
parent | bdb881fdb37218e7530190c47f7836ed5bc91de1 (diff) | |
parent | d4dda0b30a81d45d6f1566ba68565d5bb5c73233 (diff) |
Merge pull request #471 from nextcloud/fix-participant-creation
Fix creating Participants
-rw-r--r-- | lib/Manager.php | 6 | ||||
-rw-r--r-- | lib/Room.php | 12 |
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/Manager.php b/lib/Manager.php index 99cc14ce7..0233cc263 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -64,13 +64,13 @@ class Manager { * @param array $row * @return Room */ - protected function createRoomObject(array $row) { + public function createRoomObject(array $row) { $activeSince = null; if (!empty($row['activeSince'])) { $activeSince = new \DateTime($row['activeSince']); } - return new Room($this->db, $this->secureRandom, $this->dispatcher, $this->hasher, (int) $row['id'], (int) $row['type'], $row['token'], $row['name'], $row['password'], (int) $row['activeGuests'], $activeSince); + return new Room($this, $this->db, $this->secureRandom, $this->dispatcher, $this->hasher, (int) $row['id'], (int) $row['type'], $row['token'], $row['name'], $row['password'], (int) $row['activeGuests'], $activeSince); } /** @@ -78,7 +78,7 @@ class Manager { * @param array $row * @return Participant */ - protected function createParticipantObject(Room $room, array $row) { + public function createParticipantObject(Room $room, array $row) { return new Participant($this->db, $room, $row['userId'], (int) $row['participantType'], (int) $row['lastPing'], $row['sessionId'], (bool) $row['inCall']); } diff --git a/lib/Room.php b/lib/Room.php index c308c946f..f1770709b 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -41,6 +41,8 @@ class Room { const GROUP_CALL = 2; const PUBLIC_CALL = 3; + /** @var Manager */ + private $manager; /** @var IDBConnection */ private $db; /** @var ISecureRandom */ @@ -73,6 +75,7 @@ class Room { /** * Room constructor. * + * @param Manager $manager * @param IDBConnection $db * @param ISecureRandom $secureRandom * @param EventDispatcherInterface $dispatcher @@ -85,7 +88,8 @@ class Room { * @param int $activeGuests * @param \DateTime|null $activeSince */ - public function __construct(IDBConnection $db, ISecureRandom $secureRandom, EventDispatcherInterface $dispatcher, IHasher $hasher, $id, $type, $token, $name, $password, $activeGuests, \DateTime $activeSince = null) { + public function __construct(Manager $manager, IDBConnection $db, ISecureRandom $secureRandom, EventDispatcherInterface $dispatcher, IHasher $hasher, $id, $type, $token, $name, $password, $activeGuests, \DateTime $activeSince = null) { + $this->manager = $manager; $this->db = $db; $this->secureRandom = $secureRandom; $this->dispatcher = $dispatcher; @@ -185,11 +189,11 @@ class Room { } if ($this->currentUser === $userId) { - $this->participant = new Participant($this->db, $this, $row['userId'], (int) $row['participantType'], (int) $row['lastPing'], $row['sessionId']); + $this->participant = $this->manager->createParticipantObject($this, $row); return $this->participant; } - return new Participant($this->db, $this, $row['userId'], (int) $row['participantType'], (int) $row['lastPing'], $row['sessionId']); + return $this->manager->createParticipantObject($this, $row); } /** @@ -215,7 +219,7 @@ class Room { throw new ParticipantNotFoundException('User is not a participant'); } - return new Participant($this->db, $this, $row['userId'], (int) $row['participantType'], (int) $row['lastPing'], $row['sessionId']); + return $this->manager->createParticipantObject($this, $row); } public function deleteRoom() { |