diff options
author | Joas Schilling <coding@schilljs.com> | 2018-09-14 12:34:24 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:15 +0100 |
commit | 69b530a44230028c278bda94984b7aaacd22a8a1 (patch) | |
tree | e88ef681df42cb2c5eda3cc08924eb6c2e0fbcbf /lib/public/Collaboration | |
parent | 49b104f3df08b453258eb1483173dc0b8c5e022b (diff) | |
download | nextcloud-server-69b530a44230028c278bda94984b7aaacd22a8a1.tar.gz nextcloud-server-69b530a44230028c278bda94984b7aaacd22a8a1.zip |
Basic implementation of resource and collection handling
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/public/Collaboration')
-rw-r--r-- | lib/public/Collaboration/Resources/ICollection.php | 52 | ||||
-rw-r--r-- | lib/public/Collaboration/Resources/IManager.php | 45 | ||||
-rw-r--r-- | lib/public/Collaboration/Resources/IProvider.php | 27 | ||||
-rw-r--r-- | lib/public/Collaboration/Resources/IResource.php | 48 | ||||
-rw-r--r-- | lib/public/Collaboration/Resources/ResourceException.php | 27 |
5 files changed, 199 insertions, 0 deletions
diff --git a/lib/public/Collaboration/Resources/ICollection.php b/lib/public/Collaboration/Resources/ICollection.php new file mode 100644 index 00000000000..408ec67401a --- /dev/null +++ b/lib/public/Collaboration/Resources/ICollection.php @@ -0,0 +1,52 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.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\Collaboration\Resources; + +/** + * @since 15.0.0 + */ +interface ICollection { + + /** + * @return IResource[] + * @since 15.0.0 + */ + public function getResources(): array; + + /** + * Adds a resource to a collection + * + * @param IResource $resource + * @throws ResourceException when the resource is already part of the collection + * @since 15.0.0 + */ + public function addResource(IResource $resource); + + /** + * Removes a resource from a collection + * + * @param IResource $resource + * @since 15.0.0 + */ + public function removeResource(IResource $resource); +} diff --git a/lib/public/Collaboration/Resources/IManager.php b/lib/public/Collaboration/Resources/IManager.php new file mode 100644 index 00000000000..9a7fda28bb4 --- /dev/null +++ b/lib/public/Collaboration/Resources/IManager.php @@ -0,0 +1,45 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.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\Collaboration\Resources; + +/** + * @since 15.0.0 + */ +interface IManager extends IProvider { + + /** + * @param int $id + * @return ICollection + * @since 15.0.0 + */ + public function getCollection(int $id): ICollection; + + /** + * @param string $type + * @param string $id + * @return IResource + * @since 15.0.0 + */ + public function getResource(string $type, string $id): IResource; + +} diff --git a/lib/public/Collaboration/Resources/IProvider.php b/lib/public/Collaboration/Resources/IProvider.php new file mode 100644 index 00000000000..06e2a6a81ee --- /dev/null +++ b/lib/public/Collaboration/Resources/IProvider.php @@ -0,0 +1,27 @@ +<?php +/** + * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.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\Collaboration\Resources; + + +interface IProvider { + +} diff --git a/lib/public/Collaboration/Resources/IResource.php b/lib/public/Collaboration/Resources/IResource.php new file mode 100644 index 00000000000..42631bc27a8 --- /dev/null +++ b/lib/public/Collaboration/Resources/IResource.php @@ -0,0 +1,48 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.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\Collaboration\Resources; + +/** + * @since 15.0.0 + */ +interface IResource { + + /** + * @return string + * @since 15.0.0 + */ + public function getType(): string; + + /** + * @return string + * @since 15.0.0 + */ + public function getId(): string; + + /** + * @param IResource $resource + * @return ICollection[] + * @since 15.0.0 + */ + public function getCollections(IResource $resource): array; +} diff --git a/lib/public/Collaboration/Resources/ResourceException.php b/lib/public/Collaboration/Resources/ResourceException.php new file mode 100644 index 00000000000..f31b2031a89 --- /dev/null +++ b/lib/public/Collaboration/Resources/ResourceException.php @@ -0,0 +1,27 @@ +<?php +/** + * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.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\Collaboration\Resources; + + +class ResourceException extends \RuntimeException { + +} |