Files
skjnldsv ae4c1065d0 feat(viewer): keep the legacy viewer API in apps/viewer until 39
Dropping the bundled app takes the OCA.Viewer global and the LoadViewer
event with it, and apps in the wild still use both: text and
recommendations ask the global what it can open, photos opens and closes
it, files_pdfviewer re-opens the current file with another handler, and
photos, maps and collectives construct the event without checking that
it exists, so their pages would fail on the missing class.

The global goes back on the page, backed by the package rather than by
the app. open() takes the paths and the loose file info apps passed
before and turns them into nodes, the getters answer from what the last
open() was given, and mimetypes answers by asking the handlers about a
file of that type. registerHandler is deliberately not here: it was
deprecated in the viewer app in August 2025 and this is where it stops.
The event stays as an empty class nobody dispatches.

Both live in apps/viewer, which is not an app: it has no appinfo, the
server autoloads the event from it and the core viewer init script
imports the bridge. The checkers that take every folder in apps/ for an
app are told so: .noopenapi, the untranslated list, and a skip in the
autoloader checker and in tests/enable_all.php for folders without an
appinfo/info.xml. psalm lints it like the others.

Every use of the global logs a warning naming the replacement and
Nextcloud 39, where the folder and those exceptions go.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
2026-10-01 15:21:14 +02:00

26 lines
821 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Viewer\Event;
use OCP\EventDispatcher\Event;
/**
* Kept so that an app still constructing or dispatching it does not fail.
* Nothing dispatches it any more: the viewer is on every page already, see
* \OC\Template\LoadViewerListener.
*
* apps/viewer is not an app, only where the legacy viewer API waits to be
* removed: the server autoloads this class, see composer.json.
*
* @since 17.0.0
* @deprecated 36.0.0 Dispatching it does nothing. Register your handler with the `@nextcloud/viewer` package and load it with `\OCP\Util::addInitScript()` instead. It will be removed in Nextcloud 39.
*/
final class LoadViewer extends Event {
}