1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MessageApp\Command; |
4
|
|
|
|
5
|
|
|
use League\Tactician\Plugins\NamedCommand\NamedCommand; |
6
|
|
|
use MessageApp\User\ApplicationUserId; |
7
|
|
|
use RemiSan\Context\Context; |
8
|
|
|
use RemiSan\Context\ContextAware; |
9
|
|
|
|
10
|
|
|
class CreateUserCommand implements NamedCommand, ContextAware |
11
|
|
|
{ |
12
|
|
|
const NAME = 'USER.CREATE'; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var ApplicationUserId |
16
|
|
|
*/ |
17
|
|
|
private $id; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var object |
21
|
|
|
*/ |
22
|
|
|
private $originalUser; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $preferredLanguage; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var Context |
31
|
3 |
|
*/ |
32
|
|
|
private $context; |
33
|
3 |
|
|
34
|
|
|
/** |
35
|
|
|
* Constructor. |
36
|
|
|
*/ |
37
|
|
|
public function __construct() |
38
|
|
|
{ |
39
|
|
|
} |
40
|
3 |
|
|
41
|
|
|
/** |
42
|
3 |
|
* @return ApplicationUserId |
43
|
|
|
*/ |
44
|
|
|
public function getId() |
45
|
|
|
{ |
46
|
|
|
return $this->id; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
3 |
|
* Returns the command name |
51
|
|
|
* |
52
|
3 |
|
* @return string |
53
|
|
|
*/ |
54
|
|
|
public function getCommandName() |
55
|
|
|
{ |
56
|
|
|
return self::NAME; |
57
|
|
|
} |
58
|
3 |
|
|
59
|
|
|
/** |
60
|
3 |
|
* Returns the user |
61
|
|
|
* |
62
|
|
|
* @return object |
63
|
|
|
*/ |
64
|
|
|
public function getOriginalUser() |
65
|
|
|
{ |
66
|
|
|
return $this->originalUser; |
67
|
|
|
} |
68
|
3 |
|
|
69
|
|
|
/** |
70
|
3 |
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function getPreferredLanguage() |
73
|
|
|
{ |
74
|
|
|
return $this->preferredLanguage; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Returns the context |
79
|
|
|
* |
80
|
|
|
* @return Context |
81
|
|
|
*/ |
82
|
3 |
|
public function getContext() |
83
|
|
|
{ |
84
|
3 |
|
return $this->context; |
85
|
|
|
} |
86
|
3 |
|
|
87
|
3 |
|
/** |
88
|
3 |
|
* Static constructor. |
89
|
|
|
* |
90
|
3 |
|
* @param ApplicationUserId $id |
91
|
|
|
* @param object $originalUser |
92
|
|
|
* @param string $preferredLanguage |
93
|
|
|
* @param Context $context |
94
|
|
|
* |
95
|
|
|
* @return CreateUserCommand |
96
|
|
|
*/ |
97
|
|
|
public static function create(ApplicationUserId $id, $originalUser, $preferredLanguage, Context $context = null) |
98
|
|
|
{ |
99
|
|
|
$obj = new self(); |
100
|
|
|
|
101
|
|
|
$obj->id = $id; |
102
|
|
|
$obj->originalUser = $originalUser; |
103
|
|
|
$obj->preferredLanguage = $preferredLanguage; |
104
|
|
|
$obj->context = $context; |
105
|
|
|
|
106
|
|
|
return $obj; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|