Skip to content

Commit 14061c3

Browse files
refactor(preview): use getProviders() in mime support and availability checks
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent 62d4694 commit 14061c3

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

lib/private/PreviewManager.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ class PreviewManager implements IPreview {
6969
private ?Generator $generator = null;
7070
protected bool $providerListDirty = false;
7171
protected bool $registeredCoreProviders = false;
72-
/**
73-
* @var array<string, list<ProviderClosure>> $providers
74-
*/
72+
73+
/** @var array<string, list<ProviderClosure>> $providers */
7574
protected array $providers = [];
7675

7776
/** @var array mime type => support status */
7877
protected array $mimeTypeSupportMap = [];
78+
7979
/** @var ?list<class-string<IProviderV2>> $defaultProviders */
8080
protected ?array $defaultProviders = null;
8181

@@ -119,9 +119,6 @@ private function registerProviderClosure(string $mimeTypeRegex, Closure $callabl
119119
$this->providerListDirty = true;
120120
}
121121

122-
/**
123-
* Get all providers
124-
*/
125122
#[\Override]
126123
public function getProviders(): array {
127124
if (!$this->enablePreviews) {
@@ -212,9 +209,7 @@ public function isMimeSupported(string $mimeType = '*'): bool {
212209
return $this->mimeTypeSupportMap[$mimeType];
213210
}
214211

215-
$this->registerCoreProviders();
216-
$this->registerBootstrapProviders();
217-
$providerMimeTypes = array_keys($this->providers);
212+
$providerMimeTypes = array_keys($this->getProviders());
218213
foreach ($providerMimeTypes as $supportedMimeType) {
219214
if (preg_match($supportedMimeType, $mimeType)) {
220215
$this->mimeTypeSupportMap[$mimeType] = true;
@@ -233,7 +228,6 @@ public function isAvailable(FileInfo $file, ?string $mimeType = null): bool {
233228

234229
$fileMimeType = $mimeType ?? $file->getMimeType();
235230

236-
$this->registerCoreProviders();
237231
if (!$this->isMimeSupported($fileMimeType)) {
238232
return false;
239233
}
@@ -243,7 +237,7 @@ public function isAvailable(FileInfo $file, ?string $mimeType = null): bool {
243237
return false;
244238
}
245239

246-
foreach ($this->providers as $supportedMimeType => $providers) {
240+
foreach ($this->getProviders() as $supportedMimeType => $providers) {
247241
if (preg_match($supportedMimeType, $fileMimeType)) {
248242
foreach ($providers as $providerClosure) {
249243
$provider = $this->helper->getProvider($providerClosure);

0 commit comments

Comments
 (0)