mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
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>
This commit is contained in:
parent
fe05882628
commit
44c7248749
2 changed files with 22 additions and 13 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,16 +12,15 @@ use OC\Collaboration\Resources\Manager;
|
|||
use OCP\Collaboration\Resources\IManager;
|
||||
use OCP\Collaboration\Resources\IProviderManager;
|
||||
use OCP\IDBConnection;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class ManagerTest extends TestCase {
|
||||
/** @var LoggerInterface */
|
||||
protected $logger;
|
||||
/** @var IProviderManager */
|
||||
protected $providerManager;
|
||||
/** @var IManager */
|
||||
protected $manager;
|
||||
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected IProviderManager&MockObject $providerManager;
|
||||
protected IManager $manager;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
Loading…
Reference in a new issue