diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-15 01:24:05 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-19 00:35:20 +0200 |
commit | 44c724874919240ccd524abce623068317e8d66e (patch) | |
tree | 366b914ec3e3b0391b01918be1d1ce9583749c25 /lib | |
parent | fe05882628aed7e4959ae7c363ba2909a75533cc (diff) | |
download | nextcloud-server-44c724874919240ccd524abce623068317e8d66e.tar.gz nextcloud-server-44c724874919240ccd524abce623068317e8d66e.zip |
refactor(Collaboration): Use non-deprecated methods
Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de>
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Collaboration/AutoComplete/Manager.php | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/private/Collaboration/AutoComplete/Manager.php b/lib/private/Collaboration/AutoComplete/Manager.php index 382b9188535..c4dd4093e69 100644 --- a/lib/private/Collaboration/AutoComplete/Manager.php +++ b/lib/private/Collaboration/AutoComplete/Manager.php @@ -7,7 +7,9 @@ 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[] */ @@ -17,7 +19,8 @@ class Manager implements IManager { protected array $sorterInstances = []; public function __construct( - private IServerContainer $container, + private ContainerInterface $container, + private LoggerInterface $logger, ) { } @@ -27,7 +30,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 ]); } @@ -41,16 +44,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; } |