|
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
|
|
|
*/ |
|
32
|
|
|
private $context; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Constructor. |
|
36
|
|
|
*/ |
|
37
|
9 |
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
9 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return ApplicationUserId |
|
43
|
|
|
*/ |
|
44
|
9 |
|
public function getId() |
|
45
|
|
|
{ |
|
46
|
9 |
|
return $this->id; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Returns the command name |
|
51
|
|
|
* |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
3 |
|
public function getCommandName() |
|
55
|
|
|
{ |
|
56
|
3 |
|
return self::NAME; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Returns the user |
|
61
|
|
|
* |
|
62
|
|
|
* @return object |
|
63
|
|
|
*/ |
|
64
|
9 |
|
public function getOriginalUser() |
|
65
|
|
|
{ |
|
66
|
9 |
|
return $this->originalUser; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return string |
|
71
|
|
|
*/ |
|
72
|
9 |
|
public function getPreferredLanguage() |
|
73
|
|
|
{ |
|
74
|
9 |
|
return $this->preferredLanguage; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Returns the context |
|
79
|
|
|
* |
|
80
|
|
|
* @return Context |
|
81
|
|
|
*/ |
|
82
|
9 |
|
public function getContext() |
|
83
|
|
|
{ |
|
84
|
9 |
|
return $this->context; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Static constructor. |
|
89
|
|
|
* |
|
90
|
|
|
* @param ApplicationUserId $id |
|
91
|
|
|
* @param object $originalUser |
|
92
|
|
|
* @param string $preferredLanguage |
|
93
|
|
|
* @param Context $context |
|
94
|
|
|
* |
|
95
|
|
|
* @return CreateUserCommand |
|
96
|
|
|
*/ |
|
97
|
9 |
|
public static function create(ApplicationUserId $id, $originalUser, $preferredLanguage, Context $context = null) |
|
98
|
|
|
{ |
|
99
|
9 |
|
$obj = new self(); |
|
100
|
|
|
|
|
101
|
9 |
|
$obj->id = $id; |
|
102
|
9 |
|
$obj->originalUser = $originalUser; |
|
103
|
9 |
|
$obj->preferredLanguage = $preferredLanguage; |
|
104
|
9 |
|
$obj->context = $context; |
|
105
|
|
|
|
|
106
|
9 |
|
return $obj; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|