aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Collaboration/Resources/Manager.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Collaboration/Resources/Manager.php')
-rw-r--r--lib/private/Collaboration/Resources/Manager.php94
1 files changed, 18 insertions, 76 deletions
diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php
index 8fc3d0dd5ea..8d1e4b13287 100644
--- a/lib/private/Collaboration/Resources/Manager.php
+++ b/lib/private/Collaboration/Resources/Manager.php
@@ -3,27 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
- *
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Collaboration\Resources;
@@ -45,26 +26,17 @@ class Manager implements IManager {
public const TABLE_RESOURCES = 'collres_resources';
public const TABLE_ACCESS_CACHE = 'collres_accesscache';
- /** @var IDBConnection */
- protected $connection;
- /** @var IProviderManager */
- protected $providerManager;
- /** @var LoggerInterface */
- protected $logger;
-
/** @var string[] */
- protected $providers = [];
-
+ protected array $providers = [];
- public function __construct(IDBConnection $connection, IProviderManager $providerManager, LoggerInterface $logger) {
- $this->connection = $connection;
- $this->providerManager = $providerManager;
- $this->logger = $logger;
+ public function __construct(
+ protected IDBConnection $connection,
+ protected IProviderManager $providerManager,
+ protected LoggerInterface $logger,
+ ) {
}
/**
- * @param int $id
- * @return ICollection
* @throws CollectionException when the collection could not be found
* @since 16.0.0
*/
@@ -81,13 +53,10 @@ class Manager implements IManager {
throw new CollectionException('Collection not found');
}
- return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name']);
+ return new Collection($this, $this->connection, (int)$row['id'], (string)$row['name']);
}
/**
- * @param int $id
- * @param IUser|null $user
- * @return ICollection
* @throws CollectionException when the collection could not be found
* @since 16.0.0
*/
@@ -113,19 +82,15 @@ class Manager implements IManager {
throw new CollectionException('Collection not found');
}
- $access = $row['access'] === null ? null : (bool) $row['access'];
+ $access = $row['access'] === null ? null : (bool)$row['access'];
if ($user instanceof IUser) {
- return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access);
+ return new Collection($this, $this->connection, (int)$row['id'], (string)$row['name'], $user, $access);
}
- return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access);
+ return new Collection($this, $this->connection, (int)$row['id'], (string)$row['name'], $user, $access);
}
/**
- * @param IUser $user
- * @param string $filter
- * @param int $limit
- * @param int $start
* @return ICollection[]
* @since 16.0.0
*/
@@ -148,7 +113,7 @@ class Manager implements IManager {
->setFirstResult($start);
if ($filter !== '') {
- $query->where($query->expr()->iLike('c.name', $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($filter) . '%')));
+ $query->andWhere($query->expr()->iLike('c.name', $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($filter) . '%')));
}
$result = $query->execute();
@@ -157,7 +122,7 @@ class Manager implements IManager {
$foundResults = 0;
while ($row = $result->fetch()) {
$foundResults++;
- $access = $row['access'] === null ? null : (bool) $row['access'];
+ $access = $row['access'] === null ? null : (bool)$row['access'];
$collection = new Collection($this, $this->connection, (int)$row['id'], (string)$row['name'], $user, $access);
if ($collection->canAccess($user)) {
$collections[] = $collection;
@@ -173,8 +138,6 @@ class Manager implements IManager {
}
/**
- * @param string $name
- * @return ICollection
* @since 16.0.0
*/
public function newCollection(string $name): ICollection {
@@ -189,9 +152,6 @@ class Manager implements IManager {
}
/**
- * @param string $type
- * @param string $id
- * @return IResource
* @since 16.0.0
*/
public function createResource(string $type, string $id): IResource {
@@ -199,10 +159,6 @@ class Manager implements IManager {
}
/**
- * @param string $type
- * @param string $id
- * @param IUser|null $user
- * @return IResource
* @throws ResourceException
* @since 16.0.0
*/
@@ -230,7 +186,7 @@ class Manager implements IManager {
throw new ResourceException('Resource not found');
}
- $access = $row['access'] === null ? null : (bool) $row['access'];
+ $access = $row['access'] === null ? null : (bool)$row['access'];
if ($user instanceof IUser) {
return new Resource($this, $this->connection, $type, $id, $user, $access);
}
@@ -239,8 +195,6 @@ class Manager implements IManager {
}
/**
- * @param ICollection $collection
- * @param IUser|null $user
* @return IResource[]
* @since 16.0.0
*/
@@ -263,7 +217,7 @@ class Manager implements IManager {
$resources = [];
$result = $query->execute();
while ($row = $result->fetch()) {
- $access = $row['access'] === null ? null : (bool) $row['access'];
+ $access = $row['access'] === null ? null : (bool)$row['access'];
$resources[] = new Resource($this, $this->connection, $row['resource_type'], $row['resource_id'], $user, $access);
}
$result->closeCursor();
@@ -274,8 +228,6 @@ class Manager implements IManager {
/**
* Get the rich object data of a resource
*
- * @param IResource $resource
- * @return array
* @since 16.0.0
*/
public function getResourceRichObject(IResource $resource): array {
@@ -294,9 +246,6 @@ class Manager implements IManager {
/**
* Can a user/guest access the collection
*
- * @param IResource $resource
- * @param IUser|null $user
- * @return bool
* @since 16.0.0
*/
public function canAccessResource(IResource $resource, ?IUser $user): bool {
@@ -325,9 +274,6 @@ class Manager implements IManager {
/**
* Can a user/guest access the collection
*
- * @param ICollection $collection
- * @param IUser|null $user
- * @return bool
* @since 16.0.0
*/
public function canAccessCollection(ICollection $collection, ?IUser $user): bool {
@@ -365,7 +311,7 @@ class Manager implements IManager {
$hasAccess = null;
$result = $query->execute();
if ($row = $result->fetch()) {
- $hasAccess = (bool) $row['access'];
+ $hasAccess = (bool)$row['access'];
}
$result->closeCursor();
@@ -385,7 +331,7 @@ class Manager implements IManager {
$hasAccess = null;
$result = $query->execute();
if ($row = $result->fetch()) {
- $hasAccess = (bool) $row['access'];
+ $hasAccess = (bool)$row['access'];
}
$result->closeCursor();
@@ -505,9 +451,6 @@ class Manager implements IManager {
$query->execute();
}
- /**
- * @param string $provider
- */
public function registerResourceProvider(string $provider): void {
$this->logger->debug('\OC\Collaboration\Resources\Manager::registerResourceProvider is deprecated', ['provider' => $provider]);
$this->providerManager->registerResourceProvider($provider);
@@ -516,7 +459,6 @@ class Manager implements IManager {
/**
* Get the resource type of the provider
*
- * @return string
* @since 16.0.0
*/
public function getType(): string {