update resource booking interfaces and add managers

Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
Georg Ehrke 2018-06-18 14:26:32 +02:00
parent b832edabbf
commit c83629674e
No known key found for this signature in database
GPG Key ID: 9D98FD9380A1CB43
8 changed files with 308 additions and 14 deletions

View File

@ -0,0 +1,71 @@
<?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);
}
/**
* removes all registered backend instances
* @return void
* @since 14.0.0
*/
public function clear() {
$this->backends = [];
}
}

View File

@ -0,0 +1,71 @@
<?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);
}
/**
* removes all registered backend instances
* @return void
* @since 14.0.0
*/
public function clear() {
$this->backends = [];
}
}

View File

@ -36,14 +36,14 @@ interface IBackend {
*
* @return IResource[]
*/
public function getAllResources();
public function getAllResources():array;
/**
* get a list of all resource identifiers in this backend
*
* @return string[]
*/
public function listAllResources();
public function listAllResources():array;
/**
* get a resource by it's id
@ -52,4 +52,12 @@ interface IBackend {
* @return IResource|null
*/
public function getResource($id);
/**
* Get unique identifier of the backend
*
* @return string
* @since 14.0.0
*/
public function getBackendIdentifier():string;
}

View File

@ -0,0 +1,58 @@
<?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 OCP\Calendar\Resource;
interface IManager {
/**
* Registers a resource backend
*
* @param IBackend $backend
* @return void
* @since 14.0.0
*/
public function registerBackend(IBackend $backend);
/**
* Unregisters a resource backend
*
* @param IBackend $backend
* @return void
* @since 14.0.0
*/
public function unregisterBackend(IBackend $backend);
/**
* @return IBackend[]
* @since 14.0.0
*/
public function getBackends():array;
/**
* removes all registered backend instances
* @return void
* @since 14.0.0
*/
public function clear();
}

View File

@ -39,7 +39,7 @@ interface IResource {
* @return string
* @since 14.0.0
*/
public function getId();
public function getId():string;
/**
* get the display name for a resource
@ -47,7 +47,7 @@ interface IResource {
* @return string
* @since 14.0.0
*/
public function getDisplayName();
public function getDisplayName():string;
/**
* Get a list of groupIds that are allowed to access this resource
@ -58,13 +58,23 @@ interface IResource {
* @return string[]
* @since 14.0.0
*/
public function getGroupRestrictions();
public function getGroupRestrictions():array;
/**
* Get the name of the backend class the room is connected with
* get email-address for resource
*
* The email address has to be globally unique
*
* @return string
* @since 14.0.0
*/
public function getBackendClassName();
public function getEMail():string;
/**
* Get corresponding backend object
*
* @return IBackend
* @since 14.0.0
*/
public function getBackend():IBackend;
}

View File

@ -36,14 +36,14 @@ interface IBackend {
*
* @return IRoom[]
*/
public function getAllRooms();
public function getAllRooms():array;
/**
* get a list of all room identifiers in this backend
*
* @return string[]
*/
public function listAllRooms();
public function listAllRooms():array;
/**
* get a room by it's id
@ -52,4 +52,12 @@ interface IBackend {
* @return IRoom|null
*/
public function getRoom($id);
/**
* Get unique identifier of the backend
*
* @return string
* @since 14.0.0
*/
public function getBackendIdentifier():string;
}

View File

@ -0,0 +1,58 @@
<?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 OCP\Calendar\Room;
interface IManager {
/**
* Registers a room backend
*
* @param IBackend $backend
* @return void
* @since 14.0.0
*/
public function registerBackend(IBackend $backend);
/**
* Unregisters a room backend
*
* @param IBackend $backend
* @return void
* @since 14.0.0
*/
public function unregisterBackend(IBackend $backend);
/**
* @return IBackend[]
* @since 14.0.0
*/
public function getBackends():array;
/**
* removes all registered backend instances
* @return void
* @since 14.0.0
*/
public function clear();
}

View File

@ -39,7 +39,7 @@ interface IRoom {
* @return string
* @since 14.0.0
*/
public function getId();
public function getId():string;
/**
* get the display name for a room
@ -47,7 +47,7 @@ interface IRoom {
* @return string
* @since 14.0.0
*/
public function getDisplayName();
public function getDisplayName():string;
/**
* Get a list of groupIds that are allowed to access this room
@ -58,13 +58,23 @@ interface IRoom {
* @return string[]
* @since 14.0.0
*/
public function getGroupRestrictions();
public function getGroupRestrictions():array;
/**
* Get the name of the backend class the room is connected with
* get email-address for room
*
* The email address has to be globally unique
*
* @return string
* @since 14.0.0
*/
public function getBackendClassName();
public function getEMail():string;
/**
* Get corresponding backend object
*
* @return IBackend
* @since 14.0.0
*/
public function getBackend():IBackend;
}