mirror of https://github.com/sualko/cloud_bbb
parent
4d9a7b8a79
commit
916cd3bd92
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\BigBlueButton\Event;
|
||||||
|
|
||||||
|
class RoomCreatedEvent extends RoomEvent {
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\BigBlueButton\Event;
|
||||||
|
|
||||||
|
class RoomDeletedEvent extends RoomEvent {
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\BigBlueButton\Event;
|
||||||
|
|
||||||
|
use OCP\EventDispatcher\Event;
|
||||||
|
use OCA\BigBlueButton\Db\Room;
|
||||||
|
|
||||||
|
class RoomEvent extends Event {
|
||||||
|
|
||||||
|
/** @var Room */
|
||||||
|
private $room;
|
||||||
|
|
||||||
|
public function __construct(Room $room) {
|
||||||
|
$this->room = $room;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRoom(): Room {
|
||||||
|
return $this->room;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,17 +6,26 @@ use Exception;
|
||||||
|
|
||||||
use OCP\AppFramework\Db\DoesNotExistException;
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
|
|
||||||
use OCA\BigBlueButton\Db\Room;
|
use OCA\BigBlueButton\Db\Room;
|
||||||
use OCA\BigBlueButton\Db\RoomMapper;
|
use OCA\BigBlueButton\Db\RoomMapper;
|
||||||
|
use OCA\BigBlueButton\Event\RoomCreatedEvent;
|
||||||
|
use OCA\BigBlueButton\Event\RoomDeletedEvent;
|
||||||
|
|
||||||
class RoomService {
|
class RoomService {
|
||||||
|
|
||||||
/** @var RoomMapper */
|
/** @var RoomMapper */
|
||||||
private $mapper;
|
private $mapper;
|
||||||
|
|
||||||
public function __construct(RoomMapper $mapper) {
|
/** @var IEventDispatcher */
|
||||||
|
private $eventDispatcher;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
RoomMapper $mapper,
|
||||||
|
IEventDispatcher $eventDispatcher) {
|
||||||
$this->mapper = $mapper;
|
$this->mapper = $mapper;
|
||||||
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll(string $userId, array $groupIds, array $circleIds): array {
|
public function findAll(string $userId, array $groupIds, array $circleIds): array {
|
||||||
|
@ -70,7 +79,11 @@ class RoomService {
|
||||||
$room->setAccess($access);
|
$room->setAccess($access);
|
||||||
$room->setUserId($userId);
|
$room->setUserId($userId);
|
||||||
|
|
||||||
return $this->mapper->insert($room);
|
$createdRoom = $this->mapper->insert($room);
|
||||||
|
|
||||||
|
$this->eventDispatcher->dispatch(RoomCreatedEvent::class, new RoomCreatedEvent($createdRoom));
|
||||||
|
|
||||||
|
return $createdRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id, $name, $welcome, $maxParticipants, $record, $access, $everyoneIsModerator, $requireModerator) {
|
public function update($id, $name, $welcome, $maxParticipants, $record, $access, $everyoneIsModerator, $requireModerator) {
|
||||||
|
@ -99,6 +112,9 @@ class RoomService {
|
||||||
try {
|
try {
|
||||||
$room = $this->mapper->find($id);
|
$room = $this->mapper->find($id);
|
||||||
$this->mapper->delete($room);
|
$this->mapper->delete($room);
|
||||||
|
|
||||||
|
$this->eventDispatcher->dispatch(RoomDeletedEvent::class, new RoomDeletedEvent($room));
|
||||||
|
|
||||||
return $room;
|
return $room;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->handleException($e);
|
$this->handleException($e);
|
||||||
|
|
Loading…
Reference in New Issue