aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments/lib/Search
diff options
context:
space:
mode:
Diffstat (limited to 'apps/comments/lib/Search')
-rw-r--r--apps/comments/lib/Search/CommentsSearchProvider.php57
-rw-r--r--apps/comments/lib/Search/LegacyProvider.php32
-rw-r--r--apps/comments/lib/Search/Result.php55
3 files changed, 31 insertions, 113 deletions
diff --git a/apps/comments/lib/Search/CommentsSearchProvider.php b/apps/comments/lib/Search/CommentsSearchProvider.php
index b36f82f8401..87a658cab1c 100644
--- a/apps/comments/lib/Search/CommentsSearchProvider.php
+++ b/apps/comments/lib/Search/CommentsSearchProvider.php
@@ -3,27 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.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/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Comments\Search;
@@ -39,39 +20,22 @@ use function array_map;
use function pathinfo;
class CommentsSearchProvider implements IProvider {
-
- private IUserManager $userManager;
- private IL10N $l10n;
- private IURLGenerator $urlGenerator;
- private LegacyProvider $legacyProvider;
-
- public function __construct(IUserManager $userManager,
- IL10N $l10n,
- IURLGenerator $urlGenerator,
- LegacyProvider $legacyProvider) {
- $this->userManager = $userManager;
- $this->l10n = $l10n;
- $this->urlGenerator = $urlGenerator;
- $this->legacyProvider = $legacyProvider;
+ public function __construct(
+ private IUserManager $userManager,
+ private IL10N $l10n,
+ private IURLGenerator $urlGenerator,
+ private LegacyProvider $legacyProvider,
+ ) {
}
- /**
- * @inheritDoc
- */
public function getId(): string {
return 'comments';
}
- /**
- * @inheritDoc
- */
public function getName(): string {
return $this->l10n->t('Comments');
}
- /**
- * @inheritDoc
- */
public function getOrder(string $route, array $routeParameters): int {
if ($route === 'files.View.index') {
// Files first
@@ -80,9 +44,6 @@ class CommentsSearchProvider implements IProvider {
return 10;
}
- /**
- * @inheritDoc
- */
public function search(IUser $user, ISearchQuery $query): SearchResult {
return SearchResult::complete(
$this->l10n->t('Comments'),
@@ -97,7 +58,7 @@ class CommentsSearchProvider implements IProvider {
$avatarUrl,
$result->name,
$path,
- $this->urlGenerator->linkToRouteAbsolute('files.view.index',[
+ $this->urlGenerator->linkToRouteAbsolute('files.view.index', [
'dir' => $pathInfo['dirname'],
'scrollto' => $pathInfo['basename'],
]),
diff --git a/apps/comments/lib/Search/LegacyProvider.php b/apps/comments/lib/Search/LegacyProvider.php
index d22caad7e3d..a269c418d06 100644
--- a/apps/comments/lib/Search/LegacyProvider.php
+++ b/apps/comments/lib/Search/LegacyProvider.php
@@ -3,39 +3,23 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @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 OCA\Comments\Search;
use OCP\Comments\IComment;
+use OCP\Comments\ICommentsManager;
use OCP\Files\Folder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IUser;
+use OCP\IUserSession;
use OCP\Search\Provider;
-use OCP\Comments\ICommentsManager;
+use OCP\Server;
use function count;
class LegacyProvider extends Provider {
-
/**
* Search for $query
*
@@ -44,8 +28,8 @@ class LegacyProvider extends Provider {
* @since 7.0.0
*/
public function search($query): array {
- $cm = \OC::$server->get(ICommentsManager::class);
- $us = \OC::$server->getUserSession();
+ $cm = Server::get(ICommentsManager::class);
+ $us = Server::get(IUserSession::class);
$user = $us->getUser();
if (!$user instanceof IUser) {
@@ -103,7 +87,7 @@ class LegacyProvider extends Provider {
* @throws NotFoundException
*/
protected function getFileForComment(Folder $userFolder, IComment $comment): Node {
- $nodes = $userFolder->getById((int) $comment->getObjectId());
+ $nodes = $userFolder->getById((int)$comment->getObjectId());
if (empty($nodes)) {
throw new NotFoundException('File not found');
}
diff --git a/apps/comments/lib/Search/Result.php b/apps/comments/lib/Search/Result.php
index ec799b7e30a..7478c110d63 100644
--- a/apps/comments/lib/Search/Result.php
+++ b/apps/comments/lib/Search/Result.php
@@ -1,26 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Michał Węgrzynek <michal.wegrzynek@malloc.com.pl>
- *
- * @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 OCA\Comments\Search;
@@ -47,10 +29,6 @@ class Result extends BaseResult {
/**
* @deprecated 20.0.0
*/
- public $authorName;
- /**
- * @deprecated 20.0.0
- */
public $path;
/**
* @deprecated 20.0.0
@@ -58,33 +36,31 @@ class Result extends BaseResult {
public $fileName;
/**
- * @param string $search
- * @param IComment $comment
- * @param string $authorName
- * @param string $path
* @throws NotFoundException
* @deprecated 20.0.0
*/
- public function __construct(string $search,
- IComment $comment,
- string $authorName,
- string $path) {
+ public function __construct(
+ string $search,
+ IComment $comment,
+ /**
+ * @deprecated 20.0.0
+ */
+ public string $authorName,
+ string $path,
+ ) {
parent::__construct(
- (int) $comment->getId(),
+ $comment->getId(),
$comment->getMessage()
- /* @todo , [link to file] */
+ /* @todo , [link to file] */
);
$this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search);
$this->authorId = $comment->getActorId();
- $this->authorName = $authorName;
$this->fileName = basename($path);
$this->path = $this->getVisiblePath($path);
}
/**
- * @param string $path
- * @return string
* @throws NotFoundException
*/
protected function getVisiblePath(string $path): string {
@@ -98,9 +74,6 @@ class Result extends BaseResult {
}
/**
- * @param string $message
- * @param string $search
- * @return string
* @throws NotFoundException
*/
protected function getRelevantMessagePart(string $message, string $search): string {