summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-03-12 12:08:31 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-03-16 12:44:11 +0100
commit1a1dc9b3356ee9d8604aff3158bd854fbfeb49e4 (patch)
treeb6816f050aa33f102ed1465e05ac3fb54f4e5d0d
parentc1f266db886cb6ff87e81af1b47da7f5f70966f9 (diff)
downloadnextcloud-server-1a1dc9b3356ee9d8604aff3158bd854fbfeb49e4.tar.gz
nextcloud-server-1a1dc9b3356ee9d8604aff3158bd854fbfeb49e4.zip
Use DI for the config
-rw-r--r--lib/private/preview/provider.php7
-rw-r--r--lib/private/previewmanager.php25
-rw-r--r--lib/private/server.php4
3 files changed, 23 insertions, 13 deletions
diff --git a/lib/private/preview/provider.php b/lib/private/preview/provider.php
index bfabc7ad4b3..caf71fd2219 100644
--- a/lib/private/preview/provider.php
+++ b/lib/private/preview/provider.php
@@ -6,7 +6,12 @@ use OCP\Preview\IProvider;
abstract class Provider implements IProvider {
private $options;
- public function __construct($options) {
+ /**
+ * Constructor
+ *
+ * @param array $options
+ */
+ public function __construct(array $options = []) {
$this->options = $options;
}
diff --git a/lib/private/previewmanager.php b/lib/private/previewmanager.php
index 732681c78e7..c940307084d 100644
--- a/lib/private/previewmanager.php
+++ b/lib/private/previewmanager.php
@@ -8,11 +8,13 @@
*/
namespace OC;
-use OCP\Image;
use OCP\IPreview;
use OCP\Preview\IProvider;
class PreviewManager implements IPreview {
+ /** @var \OCP\IConfig */
+ protected $config;
+
/** @var array */
protected $providers = [];
@@ -21,8 +23,11 @@ class PreviewManager implements IPreview {
/**
* Constructor
+ *
+ * @param \OCP\IConfig $config
*/
- public function __construct() {
+ public function __construct(\OCP\IConfig $config) {
+ $this->config = $config;
$this->registerCoreProviders();
}
@@ -37,7 +42,7 @@ class PreviewManager implements IPreview {
* @return void
*/
public function registerProvider($mimeTypeRegex, \Closure $callable) {
- if (!\OC::$server->getConfig()->getSystemValue('enable_previews', true)) {
+ if (!$this->config->getSystemValue('enable_previews', true)) {
return;
}
@@ -87,7 +92,7 @@ class PreviewManager implements IPreview {
* @return boolean
*/
public function isMimeSupported($mimeType = '*') {
- if (!\OC::$server->getConfig()->getSystemValue('enable_previews', true)) {
+ if (!$this->config->getSystemValue('enable_previews', true)) {
return false;
}
@@ -107,7 +112,7 @@ class PreviewManager implements IPreview {
* @return bool
*/
public function isAvailable(\OCP\Files\FileInfo $file) {
- if (!\OC::$server->getConfig()->getSystemValue('enable_previews', true)) {
+ if (!$this->config->getSystemValue('enable_previews', true)) {
return false;
}
@@ -165,7 +170,7 @@ class PreviewManager implements IPreview {
return $this->defaultProviders;
}
- $this->defaultProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', [
+ $this->defaultProviders = $this->config->getSystemValue('enabledPreviewProviders', [
'OC\Preview\Image',
'OC\Preview\MP3',
'OC\Preview\TXT',
@@ -180,10 +185,10 @@ class PreviewManager implements IPreview {
* @param string $class
* @param string $mimeType
*/
- protected function registerCoreProvider($class, $mimeType) {
+ protected function registerCoreProvider($class, $mimeType, $options = []) {
if (in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) {
- $this->registerProvider($mimeType, function () use ($class) {
- return new $class([]);
+ $this->registerProvider($mimeType, function () use ($class, $options) {
+ return new $class($options);
});
}
}
@@ -225,7 +230,7 @@ class PreviewManager implements IPreview {
if (count($checkImagick->queryFormats('PDF')) === 1) {
// Office previews are currently not supported on Windows
if (!\OC_Util::runningOnWindows() && \OC_Helper::is_function_enabled('shell_exec')) {
- $officeFound = is_string(\OC::$server->getConfig()->getSystemValue('preview_libreoffice_path', null));
+ $officeFound = is_string($this->config->getSystemValue('preview_libreoffice_path', null));
if (!$officeFound) {
//let's see if there is libreoffice or openoffice on this machine
diff --git a/lib/private/server.php b/lib/private/server.php
index 896abf04a40..8c78549d06e 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -43,8 +43,8 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('ContactsManager', function ($c) {
return new ContactsManager();
});
- $this->registerService('PreviewManager', function ($c) {
- return new PreviewManager();
+ $this->registerService('PreviewManager', function (Server $c) {
+ return new PreviewManager($c->getConfig());
});
$this->registerService('TagMapper', function(Server $c) {
return new TagMapper($c->getDatabaseConnection());