aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Listener
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-10-15 20:35:30 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-10-15 20:35:30 +0200
commitbcfb02f5d79796cae2fe45b9b64926eae51680a1 (patch)
tree0f7d9354cb12f89b70564e30be5d61a936d8cb27 /apps/files/lib/Listener
parent9a7e1bb2276f4a4635cd330fbc2a385ebaeed5ee (diff)
downloadnextcloud-server-bcfb02f5d79796cae2fe45b9b64926eae51680a1.tar.gz
nextcloud-server-bcfb02f5d79796cae2fe45b9b64926eae51680a1.zip
refactor(files): Migrate from event listener to class based declarative settingsfeat/allow-getter-setter-decl-fors
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/lib/Listener')
-rw-r--r--apps/files/lib/Listener/DeclarativeSettingsGetValueEventListener.php39
-rw-r--r--apps/files/lib/Listener/DeclarativeSettingsRegisterFormEventListener.php50
-rw-r--r--apps/files/lib/Listener/DeclarativeSettingsSetValueEventListener.php40
3 files changed, 0 insertions, 129 deletions
diff --git a/apps/files/lib/Listener/DeclarativeSettingsGetValueEventListener.php b/apps/files/lib/Listener/DeclarativeSettingsGetValueEventListener.php
deleted file mode 100644
index b1d0ee3a395..00000000000
--- a/apps/files/lib/Listener/DeclarativeSettingsGetValueEventListener.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-declare(strict_types=1);
-/**
- * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-namespace OCA\Files\Listener;
-
-use OCA\Files\AppInfo\Application;
-use OCA\Files\Service\SettingsService;
-use OCP\EventDispatcher\Event;
-use OCP\EventDispatcher\IEventListener;
-use OCP\Settings\Events\DeclarativeSettingsGetValueEvent;
-
-/** @template-implements IEventListener<DeclarativeSettingsGetValueEvent> */
-class DeclarativeSettingsGetValueEventListener implements IEventListener {
-
- public function __construct(
- private SettingsService $service,
- ) {
- }
-
- public function handle(Event $event): void {
- if (!($event instanceof DeclarativeSettingsGetValueEvent)) {
- return;
- }
-
- if ($event->getApp() !== Application::APP_ID) {
- return;
- }
-
- $event->setValue(
- match($event->getFieldId()) {
- 'windows_support' => $this->service->hasFilesWindowsSupport(),
- }
- );
- }
-}
diff --git a/apps/files/lib/Listener/DeclarativeSettingsRegisterFormEventListener.php b/apps/files/lib/Listener/DeclarativeSettingsRegisterFormEventListener.php
deleted file mode 100644
index 51832e89ecb..00000000000
--- a/apps/files/lib/Listener/DeclarativeSettingsRegisterFormEventListener.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-declare(strict_types=1);
-/**
- * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-namespace OCA\Files\Listener;
-
-use OCA\Files\AppInfo\Application;
-use OCP\EventDispatcher\Event;
-use OCP\EventDispatcher\IEventListener;
-use OCP\IL10N;
-use OCP\Settings\DeclarativeSettingsTypes;
-use OCP\Settings\Events\DeclarativeSettingsRegisterFormEvent;
-
-/** @template-implements IEventListener<DeclarativeSettingsRegisterFormEvent> */
-class DeclarativeSettingsRegisterFormEventListener implements IEventListener {
-
- public function __construct(
- private IL10N $l,
- ) {
- }
-
- public function handle(Event $event): void {
- if (!($event instanceof DeclarativeSettingsRegisterFormEvent)) {
- return;
- }
-
- $event->registerSchema(Application::APP_ID, [
- 'id' => 'files-filename-support',
- 'priority' => 10,
- 'section_type' => DeclarativeSettingsTypes::SECTION_TYPE_ADMIN,
- 'section_id' => 'server',
- 'storage_type' => DeclarativeSettingsTypes::STORAGE_TYPE_EXTERNAL,
- 'title' => $this->l->t('Files compatibility'),
- 'description' => $this->l->t('Allow to restrict filenames to ensure files can be synced with all clients. By default all filenames valid on POSIX (e.g. Linux or macOS) are allowed.'),
-
- 'fields' => [
- [
- 'id' => 'windows_support',
- 'title' => $this->l->t('Enforce Windows compatibility'),
- 'description' => $this->l->t('This will block filenames not valid on Windows systems, like using reserved names or special characters. But this will not enforce compatibility of case sensitivity.'),
- 'type' => DeclarativeSettingsTypes::CHECKBOX,
- 'default' => false,
- ],
- ],
- ]);
- }
-}
diff --git a/apps/files/lib/Listener/DeclarativeSettingsSetValueEventListener.php b/apps/files/lib/Listener/DeclarativeSettingsSetValueEventListener.php
deleted file mode 100644
index a3be2b9141e..00000000000
--- a/apps/files/lib/Listener/DeclarativeSettingsSetValueEventListener.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-declare(strict_types=1);
-/**
- * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-namespace OCA\Files\Listener;
-
-use OCA\Files\AppInfo\Application;
-use OCA\Files\Service\SettingsService;
-use OCP\EventDispatcher\Event;
-use OCP\EventDispatcher\IEventListener;
-use OCP\Settings\Events\DeclarativeSettingsSetValueEvent;
-
-/** @template-implements IEventListener<DeclarativeSettingsSetValueEvent> */
-class DeclarativeSettingsSetValueEventListener implements IEventListener {
-
- public function __construct(
- private SettingsService $service,
- ) {
- }
-
- public function handle(Event $event): void {
- if (!($event instanceof DeclarativeSettingsSetValueEvent)) {
- return;
- }
-
- if ($event->getApp() !== Application::APP_ID) {
- return;
- }
-
- switch ($event->getFieldId()) {
- case 'windows_support':
- $this->service->setFilesWindowsSupport((bool)$event->getValue());
- $event->stopPropagation();
- break;
- }
- }
-}