From bcfb02f5d79796cae2fe45b9b64926eae51680a1 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 15 Oct 2024 20:35:30 +0200 Subject: refactor(files): Migrate from event listener to class based declarative settings Signed-off-by: Ferdinand Thiessen --- .../DeclarativeSettingsGetValueEventListener.php | 39 ----------------- ...eclarativeSettingsRegisterFormEventListener.php | 50 ---------------------- .../DeclarativeSettingsSetValueEventListener.php | 40 ----------------- 3 files changed, 129 deletions(-) delete mode 100644 apps/files/lib/Listener/DeclarativeSettingsGetValueEventListener.php delete mode 100644 apps/files/lib/Listener/DeclarativeSettingsRegisterFormEventListener.php delete mode 100644 apps/files/lib/Listener/DeclarativeSettingsSetValueEventListener.php (limited to 'apps/files/lib/Listener') 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 @@ - */ -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 @@ - */ -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 @@ - */ -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; - } - } -} -- cgit v1.2.3