/** @var \OCP\IConfig */
protected $config;
+ /** @var array */
+ protected $providerListDirty = false;
+
/** @var array */
protected $providers = [];
$this->providers[$mimeTypeRegex] = [];
}
$this->providers[$mimeTypeRegex][] = $callable;
+ $this->providerListDirty = true;
}
/**
* @return array
*/
public function getProviders() {
- $keys = array_map('strlen', array_keys($this->providers));
- array_multisort($keys, SORT_DESC, $this->providers);
+ if (!$this->config->getSystemValue('enable_previews', true)) {
+ return [];
+ }
+
+ if ($this->providerListDirty) {
+ $keys = array_map('strlen', array_keys($this->providers));
+ array_multisort($keys, SORT_DESC, $this->providers);
+ $this->providerListDirty = false;
+ }
return $this->providers;
}