diff options
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/Notification/IManager.php | 2 | ||||
-rw-r--r-- | lib/public/Notification/INotifier.php | 5 | ||||
-rw-r--r-- | lib/public/Notification/IPreloadableNotifier.php | 31 | ||||
-rw-r--r-- | lib/public/TaskProcessing/IManager.php | 1 |
4 files changed, 38 insertions, 1 deletions
diff --git a/lib/public/Notification/IManager.php b/lib/public/Notification/IManager.php index 23664af17cd..207a89344b0 100644 --- a/lib/public/Notification/IManager.php +++ b/lib/public/Notification/IManager.php @@ -11,7 +11,7 @@ namespace OCP\Notification; use OCP\AppFramework\Attribute\Consumable; #[Consumable(since: '9.0.0')] -interface IManager extends IApp, INotifier { +interface IManager extends IApp, IPreloadableNotifier { /** * @param string $appClass The service must implement IApp, otherwise a * \InvalidArgumentException is thrown later diff --git a/lib/public/Notification/INotifier.php b/lib/public/Notification/INotifier.php index bdc7207216f..b6851e3dfb3 100644 --- a/lib/public/Notification/INotifier.php +++ b/lib/public/Notification/INotifier.php @@ -10,6 +10,11 @@ namespace OCP\Notification; use OCP\AppFramework\Attribute\Implementable; +/** + * Please consider implementing {@see IPreloadableNotifier} to improve performance. It allows to + * preload and cache data for many notifications at once instead of loading the data for each + * prepared notification separately. + */ #[Implementable(since: '9.0.0')] interface INotifier { /** diff --git a/lib/public/Notification/IPreloadableNotifier.php b/lib/public/Notification/IPreloadableNotifier.php new file mode 100644 index 00000000000..2bdcd84d254 --- /dev/null +++ b/lib/public/Notification/IPreloadableNotifier.php @@ -0,0 +1,31 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Notification; + +use OCP\AppFramework\Attribute\Implementable; + +/** + * Allow notifier implementations to preload and cache data for many notifications at once to + * improve performance by, for example, bundling SQL queries. + */ +#[Implementable(since: '32.0.0')] +interface IPreloadableNotifier extends INotifier { + /** + * This method provides a way for notifier implementations to preload and cache data for many + * notifications. The data is meant to be consumed later in the {@see INotifier::prepare()} + * method to improve performance. + * + * @since 32.0.0 + * + * @param INotification[] $notifications The notifications which are about to be prepared in the next step. + * @param string $languageCode The code of the language that should be used to prepare the notification. + */ + public function preloadDataForParsing(array $notifications, string $languageCode): void; +} diff --git a/lib/public/TaskProcessing/IManager.php b/lib/public/TaskProcessing/IManager.php index f161030f5f4..723eca8f615 100644 --- a/lib/public/TaskProcessing/IManager.php +++ b/lib/public/TaskProcessing/IManager.php @@ -26,6 +26,7 @@ use OCP\TaskProcessing\Exception\ValidationException; * @since 30.0.0 */ interface IManager { + /** * @since 30.0.0 */ |