summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-06-29 06:51:49 +0200
committerGitHub <noreply@github.com>2018-06-29 06:51:49 +0200
commit89b6ee1a45f165346ddcc9120195714087287b47 (patch)
treea7951e212e099f08cd28b412aaa03b1fe1757523 /lib/private
parente6780c4fc7fe0bb6ee6d2a8d4bfb2ca09d6e726a (diff)
parentab43251a45f9b04a1681a0b206d85676232dd7c3 (diff)
downloadnextcloud-server-89b6ee1a45f165346ddcc9120195714087287b47.tar.gz
nextcloud-server-89b6ee1a45f165346ddcc9120195714087287b47.zip
Merge pull request #9773 from nextcloud/feature/noid/resource_booking
resource booking
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Calendar/Resource/Manager.php83
-rw-r--r--lib/private/Calendar/Room/Manager.php83
-rw-r--r--lib/private/Server.php20
3 files changed, 186 insertions, 0 deletions
diff --git a/lib/private/Calendar/Resource/Manager.php b/lib/private/Calendar/Resource/Manager.php
new file mode 100644
index 00000000000..2d1746cb989
--- /dev/null
+++ b/lib/private/Calendar/Resource/Manager.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Calendar\Resource;
+
+use OCP\Calendar\Resource\IBackend;
+
+class Manager implements \OCP\Calendar\Resource\IManager {
+
+ /** @var IBackend[] holds all registered resource backends */
+ private $backends;
+
+ /**
+ * Registers a resource backend
+ *
+ * @param IBackend $backend
+ * @return void
+ * @since 14.0.0
+ */
+ public function registerBackend(IBackend $backend) {
+ $this->backends[$backend->getBackendIdentifier()] = $backend;
+ }
+
+ /**
+ * Unregisters a resource backend
+ *
+ * @param IBackend $backend
+ * @return void
+ * @since 14.0.0
+ */
+ public function unregisterBackend(IBackend $backend) {
+ unset($this->backends[$backend->getBackendIdentifier()]);
+ }
+
+ /**
+ * @return IBackend[]
+ * @since 14.0.0
+ */
+ public function getBackends():array {
+ return array_values($this->backends);
+ }
+
+ /**
+ * @param string $backendId
+ * @return IBackend|null
+ */
+ public function getBackend($backendId):IBackend {
+ if (!isset($this->backends[$backendId])) {
+ return null;
+ }
+
+ return $this->backends[$backendId];
+ }
+
+ /**
+ * removes all registered backend instances
+ * @return void
+ * @since 14.0.0
+ */
+ public function clear() {
+ $this->backends = [];
+ }
+}
diff --git a/lib/private/Calendar/Room/Manager.php b/lib/private/Calendar/Room/Manager.php
new file mode 100644
index 00000000000..9ddf1f1d7b7
--- /dev/null
+++ b/lib/private/Calendar/Room/Manager.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Calendar\Room;
+
+use OCP\Calendar\Room\IBackend;
+
+class Manager implements \OCP\Calendar\Room\IManager {
+
+ /** @var IBackend[] holds all registered resource backends */
+ private $backends;
+
+ /**
+ * Registers a resource backend
+ *
+ * @param IBackend $backend
+ * @return void
+ * @since 14.0.0
+ */
+ public function registerBackend(IBackend $backend) {
+ $this->backends[$backend->getBackendIdentifier()] = $backend;
+ }
+
+ /**
+ * Unregisters a resource backend
+ *
+ * @param IBackend $backend
+ * @return void
+ * @since 14.0.0
+ */
+ public function unregisterBackend(IBackend $backend) {
+ unset($this->backends[$backend->getBackendIdentifier()]);
+ }
+
+ /**
+ * @return IBackend[]
+ * @since 14.0.0
+ */
+ public function getBackends():array {
+ return array_values($this->backends);
+ }
+
+ /**
+ * @param string $backendId
+ * @return IBackend|null
+ */
+ public function getBackend($backendId):IBackend {
+ if (!isset($this->backends[$backendId])) {
+ return null;
+ }
+
+ return $this->backends[$backendId];
+ }
+
+ /**
+ * removes all registered backend instances
+ * @return void
+ * @since 14.0.0
+ */
+ public function clear() {
+ $this->backends = [];
+ }
+}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 7824638b212..3c15873206d 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -174,6 +174,12 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
$this->registerAlias('CalendarManager', \OC\Calendar\Manager::class);
+ $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
+ $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
+
+ $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
+ $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
+
$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
@@ -1163,6 +1169,20 @@ class Server extends ServerContainer implements IServerContainer {
return $this->query('CalendarManager');
}
+ /**
+ * @return \OCP\Calendar\Resource\IManager
+ */
+ public function getCalendarResourceBackendManager() {
+ return $this->query('CalendarResourceBackendManager');
+ }
+
+ /**
+ * @return \OCP\Calendar\Room\IManager
+ */
+ public function getCalendarRoomBackendManager() {
+ return $this->query('CalendarRoomBackendManager');
+ }
+
private function connectDispatcher() {
$dispatcher = $this->getEventDispatcher();