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/AppInfo | |
parent | 2c8b4fa019749113658b9ed8cae211b679e4cbc0 (diff) |
Move to nextcloud config and update phpunit
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/AppInfo')
-rw-r--r-- | lib/AppInfo/Application.php | 80 |
1 files changed, 37 insertions, 43 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index b0d2d1e4f..005a264a4 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -18,28 +18,32 @@ use HTMLPurifier; use HTMLPurifier_Config; use Favicon\Favicon; +use OC\Encryption\Update; +use OCA\News\Config\LegacyConfig; use OCA\News\Config\FetcherConfig; +use OCA\News\Db\FolderMapper; +use OCA\News\Service\FeedService; +use OCA\News\Service\FolderService; +use OCA\News\Service\ItemService; use OCA\News\Utility\PsrLogger; -use OCP\BackgroundJob\IJobList; +use OCA\News\Utility\Updater; use OCP\IContainer; -use OCP\INavigationManager; -use OCP\IURLGenerator; use OCP\IConfig; +use OCP\ILogger; use OCP\ITempManager; use OCP\AppFramework\App; use OCP\Files\IRootFolder; use OCP\Files\Node; -use OCA\News\Config\AppConfig; -use OCA\News\Config\Config; use OCA\News\Db\MapperFactory; use OCA\News\Db\ItemMapper; use OCA\News\Fetcher\FeedFetcher; use OCA\News\Fetcher\Fetcher; use OCA\News\Fetcher\YoutubeFetcher; use OCA\News\Scraper\Scraper; +use Psr\Log\LoggerInterface; /** * Class Application @@ -50,13 +54,31 @@ class Application extends App { /** + * App Name + */ + public const NAME = 'news'; + + /** + * List of default settings + */ + public const DEFAULT_SETTINGS = [ + 'autoPurgeMinimumInterval' => 60, + 'autoPurgeCount' => 200, + 'maxRedirects' => 10, + 'feedFetcherTimeout' => 60, + 'useCronUpdates' => true, + 'exploreUrl' => '', + 'updateInterval' => 3600, + ]; + + /** * Application constructor. * * @param array $urlParams Parameters */ public function __construct(array $urlParams = []) { - parent::__construct('news', $urlParams); + parent::__construct(self::NAME, $urlParams); $container = $this->getContainer(); @@ -78,58 +100,30 @@ class Application extends App }); /** - * App config parser. - */ - $container->registerService(AppConfig::class, function (IContainer $c): AppConfig { - $config = new AppConfig( - $c->query(INavigationManager::class), - $c->query(IURLGenerator::class), - $c->query(IJobList::class) - ); - - $config->loadConfig($c->query('info')); - return $config; - }); - - /** * Core */ $container->registerService('LoggerParameters', function (IContainer $c): array { return ['app' => $c->query('AppName')]; }); - $container->registerService('databaseType', function (IContainer $c) { - return $c->query(IConfig::class)->getSystemValue('dbtype'); - }); - - $container->registerService('ConfigView', function (IContainer $c): Node { + $container->registerService('ConfigView', function (IContainer $c): ?Node { /** @var IRootFolder $fs */ $fs = $c->query(IRootFolder::class); $path = 'news/config'; if ($fs->nodeExists($path)) { return $fs->get($path); } else { - return $fs->newFolder($path); + return null; } }); - /** - * Logger base - */ - $container->registerService(PsrLogger::class, function (IContainer $c): PsrLogger { - return new PsrLogger( - $c->query('ServerContainer')->getLogger(), - $c->query('AppName') - ); - }); - - $container->registerService(Config::class, function (IContainer $c): Config { - $config = new Config( + $container->registerService(LegacyConfig::class, function (IContainer $c): LegacyConfig { + $config = new LegacyConfig( $c->query('ConfigView'), - $c->query(PsrLogger::class), + $c->query(LoggerInterface::class), $c->query('LoggerParameters') ); - $config->read($c->query('configFile'), true); + $config->read($c->query('configFile'), false); return $config; }); @@ -175,7 +169,7 @@ class Application extends App */ $container->registerService(FetcherConfig::class, function (IContainer $c): FetcherConfig { $fConfig = new FetcherConfig(); - $fConfig->setConfig($c->query(Config::class)) + $fConfig->setConfig($c->query(IConfig::class)) ->setProxy($c->query(IConfig::class)); return $fConfig; @@ -183,7 +177,7 @@ class Application extends App $container->registerService(FeedIo::class, function (IContainer $c): FeedIo { $config = $c->query(FetcherConfig::class); - return new FeedIo($config->getClient(), $c->query(PsrLogger::class)); + return new FeedIo($config->getClient(), $c->query(LoggerInterface::class)); }); $container->registerService(Favicon::class, function (IContainer $c): Favicon { @@ -209,7 +203,7 @@ class Application extends App */ $container->registerService(Scraper::class, function (IContainer $c): Scraper { return new Scraper( - $c->query(PsrLogger::class) + $c->query(LoggerInterface::class) ); }); } |