From 65a9ab47ea233701b559d08d89e36649a3d5a30b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Oct 2018 17:48:16 +0200 Subject: Add a controller with the most important methods Signed-off-by: Joas Schilling --- lib/private/Collaboration/Resources/Resource.php | 7 +++--- .../Resources/CollectionException.php | 28 ++++++++++++++++++++++ lib/public/Collaboration/Resources/IProvider.php | 1 + lib/public/Collaboration/Resources/IResource.php | 3 +-- .../Collaboration/Resources/ResourceException.php | 1 + 5 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 lib/public/Collaboration/Resources/CollectionException.php (limited to 'lib') diff --git a/lib/private/Collaboration/Resources/Resource.php b/lib/private/Collaboration/Resources/Resource.php index f82ceff5596..0eda8ba55c2 100644 --- a/lib/private/Collaboration/Resources/Resource.php +++ b/lib/private/Collaboration/Resources/Resource.php @@ -66,19 +66,18 @@ class Resource implements IResource { } /** - * @param IResource $resource * @return ICollection[] * @since 15.0.0 */ - public function getCollections(IResource $resource): array { + public function getCollections(): array { $collections = []; $query = $this->connection->getQueryBuilder(); $query->select('collection_id') ->from('collres_resources') - ->where($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType()))) - ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId()))); + ->where($query->expr()->eq('resource_type', $query->createNamedParameter($this->getType()))) + ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($this->getId()))); $result = $query->execute(); while ($row = $result->fetch()) { diff --git a/lib/public/Collaboration/Resources/CollectionException.php b/lib/public/Collaboration/Resources/CollectionException.php new file mode 100644 index 00000000000..f5130d37d60 --- /dev/null +++ b/lib/public/Collaboration/Resources/CollectionException.php @@ -0,0 +1,28 @@ + + * + * @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 . + * + */ + +namespace OCP\Collaboration\Resources; + + +class CollectionException extends \RuntimeException { + +} diff --git a/lib/public/Collaboration/Resources/IProvider.php b/lib/public/Collaboration/Resources/IProvider.php index 06e2a6a81ee..eac92733dea 100644 --- a/lib/public/Collaboration/Resources/IProvider.php +++ b/lib/public/Collaboration/Resources/IProvider.php @@ -1,4 +1,5 @@ * diff --git a/lib/public/Collaboration/Resources/IResource.php b/lib/public/Collaboration/Resources/IResource.php index 42631bc27a8..9f8628c0d48 100644 --- a/lib/public/Collaboration/Resources/IResource.php +++ b/lib/public/Collaboration/Resources/IResource.php @@ -40,9 +40,8 @@ interface IResource { public function getId(): string; /** - * @param IResource $resource * @return ICollection[] * @since 15.0.0 */ - public function getCollections(IResource $resource): array; + public function getCollections(): array; } diff --git a/lib/public/Collaboration/Resources/ResourceException.php b/lib/public/Collaboration/Resources/ResourceException.php index f31b2031a89..d03264bcef9 100644 --- a/lib/public/Collaboration/Resources/ResourceException.php +++ b/lib/public/Collaboration/Resources/ResourceException.php @@ -1,4 +1,5 @@ * -- cgit v1.2.3