aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php
diff options
context:
space:
mode:
authorOleksander Piskun <oleksandr2088@icloud.com>2025-04-08 20:45:37 +0300
committerOleksander Piskun <oleksandr2088@icloud.com>2025-04-09 15:47:48 +0300
commitc23ab0d1f7ca6985f873035c8801d0c3244cc2d2 (patch)
tree220fc1fb01009c0dabb4624b92956edfe72e8b17 /lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php
parent90a3928cdb2f390f2018e819b26c62255322be4d (diff)
downloadnextcloud-server-fix/noid/taskprocessing-appapi.tar.gz
nextcloud-server-fix/noid/taskprocessing-appapi.zip
fix(taskprocessing): use the event for AppAPI to get list of AI providersfix/noid/taskprocessing-appapi
Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
Diffstat (limited to 'lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php')
-rw-r--r--lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php b/lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php
new file mode 100644
index 00000000000..10c94d20406
--- /dev/null
+++ b/lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\TaskProcessing\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\TaskProcessing\IProvider;
+use OCP\TaskProcessing\ITaskType;
+
+/**
+ * Event dispatched by the server to collect Task Processing Providers
+ * and custom Task Types from listeners (like AppAPI).
+ *
+ * Listeners should add their providers and task types using the
+ * addProvider() and addTaskType() methods.
+ *
+ * @since 32.0.0
+ */
+class GetTaskProcessingProvidersEvent extends Event {
+ /** @var IProvider[] */
+ private array $providers = [];
+
+ /** @var ITaskType[] */
+ private array $taskTypes = [];
+
+ /**
+ * Add a Task Processing Provider.
+ *
+ * @param IProvider $provider The provider instance to add.
+ * @since 32.0.0
+ */
+ public function addProvider(IProvider $provider): void {
+ $this->providers[] = $provider;
+ }
+
+ /**
+ * Get all collected Task Processing Providers.
+ *
+ * @return IProvider[]
+ * @since 32.0.0
+ */
+ public function getProviders(): array {
+ return $this->providers;
+ }
+
+ /**
+ * Add a custom Task Processing Task Type.
+ *
+ * @param ITaskType $taskType The task type instance to add.
+ * @since 32.0.0
+ */
+ public function addTaskType(ITaskType $taskType): void {
+ $this->taskTypes[] = $taskType;
+ }
+
+ /**
+ * Get all collected custom Task Processing Task Types.
+ *
+ * @return ITaskType[]
+ * @since 32.0.0
+ */
+ public function getTaskTypes(): array {
+ return $this->taskTypes;
+ }
+}