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