diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2020-09-20 22:03:05 +0200 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2020-09-25 19:18:04 +0200 |
commit | 60ab4941cc7e6ede095e9e4aee3c2bf9a5c3bff6 (patch) | |
tree | baf0b07dd1c545efeb59437af46a99f4d9f69425 /lib/Service | |
parent | 2c8b4fa019749113658b9ed8cae211b679e4cbc0 (diff) |
Move to nextcloud config and update phpunit
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Service')
-rw-r--r-- | lib/Service/FeedService.php | 15 | ||||
-rw-r--r-- | lib/Service/FolderService.php | 16 | ||||
-rw-r--r-- | lib/Service/ItemService.php | 15 | ||||
-rw-r--r-- | lib/Service/StatusService.php | 16 |
4 files changed, 34 insertions, 28 deletions
diff --git a/lib/Service/FeedService.php b/lib/Service/FeedService.php index aff9626d8..6d57c8027 100644 --- a/lib/Service/FeedService.php +++ b/lib/Service/FeedService.php @@ -16,6 +16,8 @@ namespace OCA\News\Service; use FeedIo\Reader\ReadErrorException; use HTMLPurifier; +use OCA\News\AppInfo\Application; +use OCP\IConfig; use OCP\ILogger; use OCP\IL10N; use OCP\AppFramework\Db\DoesNotExistException; @@ -25,7 +27,6 @@ use OCA\News\Db\Item; use OCA\News\Db\FeedMapper; use OCA\News\Db\ItemMapper; use OCA\News\Fetcher\Fetcher; -use OCA\News\Config\Config; use OCA\News\Utility\Time; class FeedService extends Service @@ -48,9 +49,8 @@ class FeedService extends Service ILogger $logger, IL10N $l10n, Time $timeFactory, - Config $config, - HTMLPurifier $purifier, - $LoggerParameters + IConfig $config, + HTMLPurifier $purifier ) { parent::__construct($feedMapper); $this->feedFetcher = $feedFetcher; @@ -58,11 +58,14 @@ class FeedService extends Service $this->logger = $logger; $this->l10n = $l10n; $this->timeFactory = $timeFactory; - $this->autoPurgeMinimumInterval = $config->getAutoPurgeMinimumInterval( + $this->autoPurgeMinimumInterval = $config->getAppValue( + Application::NAME, + 'autoPurgeMinimumInterval', + Application::DEFAULT_SETTINGS['autoPurgeMinimumInterval'] ); $this->purifier = $purifier; $this->feedMapper = $feedMapper; - $this->loggerParams = $LoggerParameters; + $this->loggerParams = ['app' => Application::NAME]; } /** diff --git a/lib/Service/FolderService.php b/lib/Service/FolderService.php index 9ba6b35e2..35eb77f95 100644 --- a/lib/Service/FolderService.php +++ b/lib/Service/FolderService.php @@ -13,10 +13,11 @@ namespace OCA\News\Service; +use OCA\News\AppInfo\Application; +use OCP\IConfig; use OCP\IL10N; use OCA\News\Db\Folder; use OCA\News\Db\FolderMapper; -use OCA\News\Config\Config; use OCA\News\Utility\Time; class FolderService extends Service @@ -31,13 +32,16 @@ class FolderService extends Service FolderMapper $folderMapper, IL10N $l10n, Time $timeFactory, - Config $config + IConfig $config ) { parent::__construct($folderMapper); $this->l10n = $l10n; $this->timeFactory = $timeFactory; - $this->autoPurgeMinimumInterval = - $config->getAutoPurgeMinimumInterval(); + $this->autoPurgeMinimumInterval = $config->getAppValue( + Application::NAME, + 'autoPurgeMinimumInterval', + Application::DEFAULT_SETTINGS['autoPurgeMinimumInterval'] + ); $this->folderMapper = $folderMapper; } @@ -91,6 +95,7 @@ class FolderService extends Service $folder->setUserId($userId); $folder->setParentId($parentId); $folder->setOpened(true); + return $this->folderMapper->insert($folder); } @@ -123,6 +128,7 @@ class FolderService extends Service $folder = $this->find($folderId, $userId); $folder->setName($folderName); + return $this->folderMapper->update($folder); } @@ -160,7 +166,7 @@ class FolderService extends Service /** * Deletes all deleted folders * - * @param string $userId if given it purges only folders of that user + * @param ?string $userId if given it purges only folders of that user * @param boolean $useInterval defaults to true, if true it only purges * entries in a given interval to give the user a chance to undo the * deletion diff --git a/lib/Service/ItemService.php b/lib/Service/ItemService.php index c41217ff6..5e1660cc0 100644 --- a/lib/Service/ItemService.php +++ b/lib/Service/ItemService.php @@ -13,13 +13,13 @@ namespace OCA\News\Service; +use OCA\News\AppInfo\Application; use OCA\News\Db\Item; use OCP\IConfig; use OCP\AppFramework\Db\DoesNotExistException; use OCA\News\Db\ItemMapper; use OCA\News\Db\FeedType; -use OCA\News\Config\Config; use OCA\News\Utility\Time; class ItemService extends Service @@ -28,19 +28,16 @@ class ItemService extends Service private $config; private $timeFactory; private $itemMapper; - private $systemConfig; public function __construct( ItemMapper $itemMapper, Time $timeFactory, - Config $config, - IConfig $systemConfig + IConfig $config ) { parent::__construct($itemMapper); - $this->config = $config; $this->timeFactory = $timeFactory; $this->itemMapper = $itemMapper; - $this->systemConfig = $systemConfig; + $this->config = $config; } @@ -255,7 +252,11 @@ class ItemService extends Service */ public function autoPurgeOld() { - $count = $this->config->getAutoPurgeCount(); + $count = $this->config->getAppValue( + Application::NAME, + 'autoPurgeCount', + Application::DEFAULT_SETTINGS['autoPurgeCount'] + ); if ($count >= 0) { $this->itemMapper->deleteReadOlderThanThreshold($count); } diff --git a/lib/Service/StatusService.php b/lib/Service/StatusService.php index 85be58a5d..f926258b6 100644 --- a/lib/Service/StatusService.php +++ b/lib/Service/StatusService.php @@ -13,17 +13,14 @@ namespace OCA\News\Service; +use OCA\News\AppInfo\Application; use OCP\IConfig; use OCP\IDBConnection; -use OCA\News\Config\Config; - class StatusService { /** @var IConfig */ private $settings; - /** @var Config */ - private $config; /** @var string */ private $appName; /** @var IDBConnection */ @@ -32,22 +29,21 @@ class StatusService public function __construct( IConfig $settings, IDBConnection $connection, - Config $config, $AppName ) { $this->settings = $settings; - $this->config = $config; $this->appName = $AppName; $this->connection = $connection; } public function isProperlyConfigured() { - $cronMode = $this->settings->getAppValue( - 'core', - 'backgroundjobs_mode' + $cronMode = $this->settings->getSystemValue('backgroundjobs_mode'); + $cronOff = !$this->settings->getAppValue( + Application::NAME, + 'useCronUpdates', + Application::DEFAULT_SETTINGS['useCronUpdates'] ); - $cronOff = !$this->config->getUseCronUpdates(); // check for cron modes which may lead to problems return $cronMode === 'cron' || $cronOff; |