diff --git a/lib/Controller/FilesController.php b/lib/Controller/FilesController.php index ce21e55fa..cd32c1ea0 100644 --- a/lib/Controller/FilesController.php +++ b/lib/Controller/FilesController.php @@ -23,9 +23,7 @@ use OCP\Files\Config\IMountProviderCollection; use OCP\Files\FileInfo; use OCP\Files\IRootFolder; -use OCP\IConfig; use OCP\IDBConnection; -use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; use OCP\AppFramework\OCSController; @@ -34,7 +32,7 @@ use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; -use OCP\RichObjectStrings\IValidator; +use OCP\Server; use Throwable; use OCP\Files\DavUtil; @@ -60,26 +58,11 @@ class FilesController extends OCSController { /** @var IDBConnection */ protected $connection; - /** - * @var IValidator - */ - private $richObjectValidator; - /** * @var ILogger */ private $logger; - /** - * @var IL10N - */ - private $l; - - /** - * @var IConfig - */ - private $config; - /** * @var IUserManager */ @@ -105,10 +88,7 @@ public function __construct(string $appName, IManager $activityManager, IAppManager $appManager, IDBConnection $connection, - IValidator $richObjectValidator, ILogger $logger, - IL10N $l, - IConfig $config, IUserManager $userManager, DavUtil $davUtils ) { @@ -118,10 +98,7 @@ public function __construct(string $appName, $this->mountCollection = $mountCollection; $this->activityManager = $activityManager; $this->connection = $connection; - $this->richObjectValidator = $richObjectValidator; $this->logger = $logger; - $this->l = $l; - $this->config = $config; $this->userManager = $userManager; $this->appManager = $appManager; $this->davUtils = $davUtils; @@ -281,20 +258,15 @@ private function getLastModifier(string $ownerId, int $fileId, int $since = 0): class_exists('\OCA\Activity\GroupHelperDisabled') && class_exists('\OCA\Activity\UserSettings') ) { - $activityData = new Data($this->activityManager, $this->connection); + $activityData = Server::get(Data::class); } else { return null; } // @phpstan-ignore-next-line - make phpstan not complain if activity app does not exist - $groupHelper = new GroupHelperDisabled( - $this->l, - $this->activityManager, - $this->richObjectValidator, - $this->logger - ); + $groupHelper = Server::get(GroupHelperDisabled::class); // @phpstan-ignore-next-line - make phpstan not complain if activity app does not exist - $userSettings = new UserSettings($this->activityManager, $this->config); + $userSettings = Server::get(UserSettings::class); if (!method_exists($activityData, 'get') || !method_exists($activityData, 'getById') ) { diff --git a/tests/lib/Controller/FilesControllerTest.php b/tests/lib/Controller/FilesControllerTest.php index 765ff115a..0181587d0 100644 --- a/tests/lib/Controller/FilesControllerTest.php +++ b/tests/lib/Controller/FilesControllerTest.php @@ -7,13 +7,10 @@ use OCP\Files\Config\ICachedMountFileInfo; use OCP\Files\DavUtil; use OCP\Files\Node; -use OCP\IConfig; use OCP\IDBConnection; -use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; use OCP\IUserManager; -use OCP\RichObjectStrings\IValidator; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use function PHPUnit\Framework\assertSame; @@ -1012,10 +1009,7 @@ private function createFilesController( $this->createMock(IManager::class), $appManagerMock, $this->createMock(IDBConnection::class), - $this->createMock(IValidator::class), $this->createMock(ILogger::class), - $this->createMock(IL10N::class), - $this->createMock(IConfig::class), $this->createMock(IUserManager::class), $this->createMock(DavUtil::class) ); @@ -1078,10 +1072,7 @@ public function getFilesControllerMock( $this->createMock(IManager::class), $appManagerMock, $this->createMock(IDBConnection::class), - $this->createMock(IValidator::class), $this->createMock(ILogger::class), - $this->createMock(IL10N::class), - $this->createMock(IConfig::class), $this->createMock(IUserManager::class), $davUtilsMock ])