1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @copyright Copyright (c) 2019 Arthur Schiwon <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @author Arthur Schiwon <[email protected]> |
9
|
|
|
* @author Christoph Wurst <[email protected]> |
10
|
|
|
* @author Julius Härtl <[email protected]> |
11
|
|
|
* |
12
|
|
|
* @license GNU AGPL version 3 or any later version |
13
|
|
|
* |
14
|
|
|
* This program is free software: you can redistribute it and/or modify |
15
|
|
|
* it under the terms of the GNU Affero General Public License as |
16
|
|
|
* published by the Free Software Foundation, either version 3 of the |
17
|
|
|
* License, or (at your option) any later version. |
18
|
|
|
* |
19
|
|
|
* This program is distributed in the hope that it will be useful, |
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
* GNU Affero General Public License for more details. |
23
|
|
|
* |
24
|
|
|
* You should have received a copy of the GNU Affero General Public License |
25
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
26
|
|
|
* |
27
|
|
|
*/ |
28
|
|
|
namespace OCP\WorkflowEngine; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Class GenericEntityEvent |
32
|
|
|
* |
33
|
|
|
* |
34
|
|
|
* @since 18.0.0 |
35
|
|
|
*/ |
36
|
|
|
class GenericEntityEvent implements IEntityEvent { |
37
|
|
|
/** @var string */ |
38
|
|
|
private $displayName; |
39
|
|
|
/** @var string */ |
40
|
|
|
private $eventName; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* GenericEntityEvent constructor. |
44
|
|
|
* |
45
|
|
|
* @since 18.0.0 |
46
|
|
|
*/ |
47
|
|
|
public function __construct(string $displayName, string $eventName) { |
48
|
|
|
if (trim($displayName) === '') { |
49
|
|
|
throw new \InvalidArgumentException('DisplayName must not be empty'); |
50
|
|
|
} |
51
|
|
|
if (trim($eventName) === '') { |
52
|
|
|
throw new \InvalidArgumentException('EventName must not be empty'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$this->displayName = trim($displayName); |
56
|
|
|
$this->eventName = trim($eventName); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* returns a translated name to be presented in the web interface. |
61
|
|
|
* |
62
|
|
|
* Example: "created" (en), "kreita" (eo) |
63
|
|
|
* |
64
|
|
|
* @since 18.0.0 |
65
|
|
|
*/ |
66
|
|
|
public function getDisplayName(): string { |
67
|
|
|
return $this->displayName; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* returns the event name that is emitted by the EventDispatcher, e.g.: |
72
|
|
|
* |
73
|
|
|
* Example: "OCA\MyApp\Factory\Cats::postCreated" |
74
|
|
|
* |
75
|
|
|
* @since 18.0.0 |
76
|
|
|
*/ |
77
|
|
|
public function getEventName(): string { |
78
|
|
|
return $this->eventName; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|