From bd6aaeee3a80030d45d193cfe5db99fe1adcca82 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 23 Mar 2023 11:16:28 -0700 Subject: [PATCH] Use DI for tq everywhere Signed-off-by: Varun Patil --- lib/Controller/GenericApiController.php | 5 +++-- lib/Controller/PublicAlbumController.php | 9 +++------ lib/Controller/PublicController.php | 12 +++++------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/Controller/GenericApiController.php b/lib/Controller/GenericApiController.php index a929db5e..1186161e 100644 --- a/lib/Controller/GenericApiController.php +++ b/lib/Controller/GenericApiController.php @@ -55,7 +55,8 @@ abstract class GenericApiController extends Controller IDBConnection $connection, IRootFolder $rootFolder, IAppManager $appManager, - LoggerInterface $logger + LoggerInterface $logger, + TimelineQuery $timelineQuery ) { parent::__construct(Application::APPNAME, $request); @@ -65,6 +66,6 @@ abstract class GenericApiController extends Controller $this->rootFolder = $rootFolder; $this->appManager = $appManager; $this->logger = $logger; - $this->timelineQuery = new TimelineQuery($connection); + $this->timelineQuery = $timelineQuery; } } diff --git a/lib/Controller/PublicAlbumController.php b/lib/Controller/PublicAlbumController.php index 81d3d530..ae819a27 100644 --- a/lib/Controller/PublicAlbumController.php +++ b/lib/Controller/PublicAlbumController.php @@ -12,7 +12,6 @@ use OCP\AppFramework\Services\IInitialState; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\IConfig; -use OCP\IDBConnection; use OCP\IURLGenerator; use OCP\IUserSession; use OCP\Util; @@ -24,7 +23,6 @@ class PublicAlbumController extends Controller protected IInitialState $initialState; protected IAppManager $appManager; protected IConfig $config; - protected IDBConnection $connection; protected IUserSession $userSession; protected IRootFolder $rootFolder; protected IURLGenerator $urlGenerator; @@ -36,21 +34,20 @@ class PublicAlbumController extends Controller IInitialState $initialState, IAppManager $appManager, IConfig $config, - IDBConnection $connection, IUserSession $userSession, IRootFolder $rootFolder, - IURLGenerator $urlGenerator + IURLGenerator $urlGenerator, + TimelineQuery $timelineQuery ) { $this->appName = $appName; $this->eventDispatcher = $eventDispatcher; $this->initialState = $initialState; $this->appManager = $appManager; $this->config = $config; - $this->connection = $connection; $this->userSession = $userSession; $this->rootFolder = $rootFolder; $this->urlGenerator = $urlGenerator; - $this->timelineQuery = new TimelineQuery($this->connection); + $this->timelineQuery = $timelineQuery; } /** diff --git a/lib/Controller/PublicController.php b/lib/Controller/PublicController.php index f2aa2877..98fe3427 100644 --- a/lib/Controller/PublicController.php +++ b/lib/Controller/PublicController.php @@ -13,7 +13,6 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\IConfig; -use OCP\IDBConnection; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; @@ -33,8 +32,8 @@ class PublicController extends AuthPublicShareController protected IShareManager $shareManager; protected IUserManager $userManager; protected IAppManager $appManager; - protected IDBConnection $db; protected IConfig $config; + protected TimelineQuery $timelineQuery; protected IShare $share; @@ -50,8 +49,8 @@ class PublicController extends AuthPublicShareController IShareManager $shareManager, IUserManager $userManager, IAppManager $appManager, - IDBConnection $db, - IConfig $config + IConfig $config, + TimelineQuery $timelineQuery ) { parent::__construct($AppName, $request, $session, $urlGenerator); $this->eventDispatcher = $eventDispatcher; @@ -61,8 +60,8 @@ class PublicController extends AuthPublicShareController $this->shareManager = $shareManager; $this->userManager = $userManager; $this->appManager = $appManager; - $this->db = $db; $this->config = $config; + $this->timelineQuery = $timelineQuery; } /** @@ -257,8 +256,7 @@ class PublicController extends AuthPublicShareController /** Get initial state of single item */ private function getSingleItemInitialState(\OCP\Files\File $file): string { - $timelineQuery = new TimelineQuery($this->db); - $photo = $timelineQuery->getSingleItem($file->getId()); + $photo = $this->timelineQuery->getSingleItem($file->getId()); return json_encode($photo); }