aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Collaboration/AutoComplete/Manager.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Collaboration/AutoComplete/Manager.php')
-rw-r--r--lib/private/Collaboration/AutoComplete/Manager.php49
1 files changed, 21 insertions, 28 deletions
diff --git a/lib/private/Collaboration/AutoComplete/Manager.php b/lib/private/Collaboration/AutoComplete/Manager.php
index 7b40165d4d8..cc5df78beea 100644
--- a/lib/private/Collaboration/AutoComplete/Manager.php
+++ b/lib/private/Collaboration/AutoComplete/Manager.php
@@ -1,41 +1,27 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @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: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Collaboration\AutoComplete;
use OCP\Collaboration\AutoComplete\IManager;
use OCP\Collaboration\AutoComplete\ISorter;
-use OCP\IServerContainer;
+use Psr\Container\ContainerExceptionInterface;
+use Psr\Container\ContainerInterface;
+use Psr\Log\LoggerInterface;
class Manager implements IManager {
/** @var string[] */
protected array $sorters = [];
- /** @var ISorter[] */
+ /** @var ISorter[] */
protected array $sorterInstances = [];
public function __construct(
- private IServerContainer $container,
+ private ContainerInterface $container,
+ private LoggerInterface $logger,
) {
}
@@ -45,7 +31,7 @@ class Manager implements IManager {
if (isset($sorterInstances[$sorter])) {
$sorterInstances[$sorter]->sort($sortArray, $context);
} else {
- $this->container->getLogger()->warning('No sorter for ID "{id}", skipping', [
+ $this->logger->warning('No sorter for ID "{id}", skipping', [
'app' => 'core', 'id' => $sorter
]);
}
@@ -59,16 +45,23 @@ class Manager implements IManager {
protected function getSorters(): array {
if (count($this->sorterInstances) === 0) {
foreach ($this->sorters as $sorter) {
- /** @var ISorter $instance */
- $instance = $this->container->resolve($sorter);
+ try {
+ $instance = $this->container->get($sorter);
+ } catch (ContainerExceptionInterface) {
+ $this->logger->notice(
+ 'Skipping not registered sorter. Class name: {class}',
+ ['app' => 'core', 'class' => $sorter],
+ );
+ continue;
+ }
if (!$instance instanceof ISorter) {
- $this->container->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}',
+ $this->logger->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}',
['app' => 'core', 'class' => $sorter]);
continue;
}
$sorterId = trim($instance->getId());
if (trim($sorterId) === '') {
- $this->container->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}',
+ $this->logger->notice('Skipping sorter with empty ID. Class name: {class}',
['app' => 'core', 'class' => $sorter]);
continue;
}