Skip to content

Commit 4700c85

Browse files
Merge pull request #59905 from nextcloud/jtr/chore-drop-registerProvider-IPreview
refactor(preview): remove deprecated `PreviewManager::registerProvider` API
2 parents 22ed3c3 + 3c1cf25 commit 4700c85

2 files changed

Lines changed: 4 additions & 19 deletions

File tree

lib/private/PreviewManager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ public function __construct(
107107
* @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
108108
* @param ProviderClosure $callable
109109
*/
110-
#[\Override]
111-
public function registerProvider(string $mimeTypeRegex, Closure $callable): void {
110+
private function registerProviderClosure(string $mimeTypeRegex, Closure $callable): void {
112111
if (!$this->enablePreviews) {
113112
return;
114113
}
@@ -300,7 +299,8 @@ protected function getEnabledDefaultProvider(): array {
300299
*/
301300
protected function registerCoreProvider(string $class, string $mimeType, array $options = []): void {
302301
if (in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) {
303-
$this->registerProvider($mimeType, function () use ($class, $options) {
302+
$this->registerProviderClosure($mimeType, function () use ($class, $options): IProviderV2 {
303+
/** @var IProviderV2 $class */
304304
return new $class($options);
305305
});
306306
}
@@ -425,7 +425,7 @@ private function registerBootstrapProviders(): void {
425425
}
426426
$this->loadedBootstrapProviders[$key] = null;
427427

428-
$this->registerProvider($provider->getMimeTypeRegex(), function () use ($provider): IProviderV2|false {
428+
$this->registerProviderClosure($provider->getMimeTypeRegex(), function () use ($provider): IProviderV2|false {
429429
try {
430430
return $this->container->get($provider->getService());
431431
} catch (NotFoundExceptionInterface) {

lib/public/IPreview.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
66
* SPDX-License-Identifier: AGPL-3.0-only
77
*/
8-
// use OCP namespace for all classes that are considered public.
9-
// This means that they should be used by apps instead of the internal Nextcloud classes
108

119
namespace OCP;
1210

@@ -35,19 +33,6 @@ interface IPreview {
3533
*/
3634
public const MODE_COVER = 'cover';
3735

38-
/**
39-
* In order to improve lazy loading a closure can be registered which will be
40-
* called in case preview providers are actually requested
41-
*
42-
* @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
43-
* @param ProviderClosure $callable
44-
* @since 8.1.0
45-
* @see \OCP\AppFramework\Bootstrap\IRegistrationContext::registerPreviewProvider
46-
*
47-
* @deprecated 23.0.0 Register your provider via the IRegistrationContext when booting the app
48-
*/
49-
public function registerProvider(string $mimeTypeRegex, Closure $callable): void;
50-
5136
/**
5237
* Get all providers
5338
* @return array<string, list<ProviderClosure>>

0 commit comments

Comments
 (0)