summaryrefslogtreecommitdiffstats
path: root/lib/Config
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-09-28 21:07:24 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-09-29 13:02:03 +0200
commitbc01761221384c0bbac0297d38e85bcaa6286a9a (patch)
treebea5acc2db33186982ba94a4270c9eb277c8f0b3 /lib/Config
parentd00d1ab2a28f428223e52b17052c072c64784016 (diff)
Fix repair step and test it
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Config')
-rw-r--r--lib/Config/DependencyException.php29
-rw-r--r--lib/Config/FetcherConfig.php104
-rw-r--r--lib/Config/LegacyConfig.php5
3 files changed, 29 insertions, 109 deletions
diff --git a/lib/Config/DependencyException.php b/lib/Config/DependencyException.php
deleted file mode 100644
index 6f9d21be6..000000000
--- a/lib/Config/DependencyException.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright 2012 Alessandro Cosentino
- * @copyright 2012-2014 Bernhard Posselt
- */
-
-namespace OCA\News\Config;
-
-class DependencyException extends \Exception
-{
-
-
- /**
- * Constructor
- *
- * @param string $msg the error message
- */
- public function __construct($msg)
- {
- parent::__construct($msg);
- }
-}
diff --git a/lib/Config/FetcherConfig.php b/lib/Config/FetcherConfig.php
index 1e9b7941e..4966f5b40 100644
--- a/lib/Config/FetcherConfig.php
+++ b/lib/Config/FetcherConfig.php
@@ -60,71 +60,11 @@ class FetcherConfig
'text/xml;q=0.4, */*;q=0.2';
/**
- * Configure a guzzle client
- *
- * @return ClientInterface Legacy client to guzzle.
- */
- public function getClient()
- {
- if (!class_exists('GuzzleHttp\Collection')) {
- return new FeedIoClient($this->getConfig());
- }
-
- return new LegacyGuzzleClient($this->getOldConfig());
- }
- /**
- * Get configuration for modern guzzle.
- * @return Client Guzzle client.
- */
- private function getConfig()
- {
- $config = [
- 'timeout' => $this->client_timeout,
- 'headers' => ['User-Agent' => static::DEFAULT_USER_AGENT, 'Accept' => static::DEFAULT_ACCEPT],
- ];
-
- if (!empty($this->proxy)) {
- $config['proxy'] = $this->proxy;
- }
- if (!empty($this->redirects)) {
- $config['redirect.max'] = $this->redirects;
- }
-
- return new Client($config);
- }
-
- /**
- * Get configuration for old guzzle.
- * @return Client Guzzle client.
- */
- private function getOldConfig()
- {
- $config = [
- 'request.options' => [
- 'timeout' => $this->client_timeout,
- 'headers' => ['User-Agent' => static::DEFAULT_USER_AGENT],
- ],
- ];
-
- if (!empty($this->proxy)) {
- $config['request.options']['proxy'] = $this->proxy;
- }
-
- if (!empty($this->redirects)) {
- $config['request.options']['redirect.max'] = $this->redirects;
- }
-
- return new Client($config);
- }
-
- /**
- * Set settings for config.
- *
- * @param IConfig $config The shared configuration
+ * FetcherConfig constructor.
*
- * @return self
+ * @param IConfig $config
*/
- public function setConfig(IConfig $config)
+ public function __construct(IConfig $config)
{
$this->client_timeout = $config->getAppValue(
Application::NAME,
@@ -137,27 +77,14 @@ class FetcherConfig
Application::DEFAULT_SETTINGS['maxRedirects']
);
- return $this;
- }
-
- /**
- * Set the proxy
- *
- * @param IConfig $config Nextcloud config.
- *
- * @return self
- */
- public function setProxy(IConfig $config)
- {
$proxy = $config->getSystemValue('proxy', null);
- $creds = $config->getSystemValue('proxyuserpwd', null);
-
if (is_null($proxy)) {
return $this;
}
$url = new \Net_URL2($proxy);
+ $creds = $config->getSystemValue('proxyuserpwd', null);
if ($creds) {
$auth = explode(':', $creds, 2);
$url->setUserinfo($auth[0], $auth[1]);
@@ -167,4 +94,27 @@ class FetcherConfig
return $this;
}
+
+ /**
+ * Configure a guzzle client
+ *
+ * @return ClientInterface Legacy client to guzzle.
+ */
+ public function getClient()
+ {
+ $config = [
+ 'timeout' => $this->client_timeout,
+ 'headers' => ['User-Agent' => static::DEFAULT_USER_AGENT, 'Accept' => static::DEFAULT_ACCEPT],
+ ];
+
+ if (!empty($this->proxy)) {
+ $config['proxy'] = $this->proxy;
+ }
+ if (!empty($this->redirects)) {
+ $config['redirect.max'] = $this->redirects;
+ }
+
+ $client = new Client($config);
+ return new FeedIoClient($client);
+ }
}
diff --git a/lib/Config/LegacyConfig.php b/lib/Config/LegacyConfig.php
index 71e19acfa..370638843 100644
--- a/lib/Config/LegacyConfig.php
+++ b/lib/Config/LegacyConfig.php
@@ -39,8 +39,7 @@ class LegacyConfig
public function __construct(
?Folder $fileSystem,
- LoggerInterface $logger,
- $LoggerParameters
+ LoggerInterface $logger
) {
$this->fileSystem = $fileSystem;
$this->autoPurgeMinimumInterval = 60;
@@ -51,7 +50,7 @@ class LegacyConfig
$this->useCronUpdates = true;
$this->logger = $logger;
$this->exploreUrl = '';
- $this->loggerParams = $LoggerParameters;
+ $this->loggerParams = ['app' => Application::NAME];
$this->updateInterval = 3600;
}