aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php
blob: 10c94d204060988a95e85f1746eea0a930dc5986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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;
	}
}