diff options
author | Joas Schilling <coding@schilljs.com> | 2018-10-24 14:25:35 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:16 +0100 |
commit | 702dcfb72848b36921a310188aa019d810668ebc (patch) | |
tree | 449f8965032eda43db1a029f4f13bebedd83029a /lib/private/Collaboration/Resources/Manager.php | |
parent | 5dfc56e925309d637be6f5a69cc16d0baaf20d03 (diff) | |
download | nextcloud-server-702dcfb72848b36921a310188aa019d810668ebc.tar.gz nextcloud-server-702dcfb72848b36921a310188aa019d810668ebc.zip |
Make names mandatory
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Collaboration/Resources/Manager.php')
-rw-r--r-- | lib/private/Collaboration/Resources/Manager.php | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index c091f5c5805..18301e0f2f5 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -23,11 +23,14 @@ declare(strict_types=1); namespace OC\Collaboration\Resources; +use OCA\Files\Collaboration\Resources\ResourceProvider; +use OCP\Collaboration\Resources\CollectionException; use OCP\Collaboration\Resources\ICollection; use OCP\Collaboration\Resources\IManager; use OCP\Collaboration\Resources\IProvider; use OCP\Collaboration\Resources\IResource; use OCP\Collaboration\Resources\ResourceException; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IUser; @@ -43,18 +46,36 @@ class Manager implements IManager { /** * @param int $id * @return ICollection + * @throws CollectionException when the collection could not be found * @since 15.0.0 */ public function getCollection(int $id): ICollection { - return new Collection($this, $this->connection, $id); + $query = $this->connection->getQueryBuilder(); + $query->select('*') + ->from('collres_collections') + ->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT))); + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + if (!$row) { + throw new CollectionException('Collection not found'); + } + + return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name']); } /** + * @param string $name * @return ICollection * @since 15.0.0 */ - public function newCollection(): ICollection { - return new Collection($this, $this->connection, 0); + public function newCollection(string $name): ICollection { + $query = $this->connection->getQueryBuilder(); + $query->insert('collres_collections'); + $query->execute(); + + return new Collection($this, $this->connection, $query->getLastInsertId(), $name); } /** @@ -72,7 +93,9 @@ class Manager implements IManager { * @since 15.0.0 */ public function getProviders(): array { - return []; + return [ + \OC::$server->query(ResourceProvider::class) // FIXME + ]; } /** |