|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Containers\User\Actions; |
|
4
|
|
|
|
|
5
|
|
|
use App\Containers\Authorization\Tasks\AssignRoleTask; |
|
6
|
|
|
use App\Containers\User\Tasks\CreateUserByCredentialsTask; |
|
7
|
|
|
use App\Containers\User\Tasks\FireUserCreatedEventTask; |
|
8
|
|
|
use App\Port\Action\Abstracts\Action; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class CreateAdminAction. |
|
12
|
|
|
* |
|
13
|
|
|
* @author Mahmoud Zalt <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
class CreateAdminAction extends Action |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var \App\Containers\User\Actions\CreateUserByCredentialsTask |
|
20
|
|
|
*/ |
|
21
|
|
|
private $createUserByCredentialsTask; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var \App\Containers\User\Actions\FireUserCreatedEventTask |
|
25
|
|
|
*/ |
|
26
|
|
|
private $fireUserCreatedEventTask; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var \App\Containers\Authorization\Tasks\AssignRoleTask |
|
30
|
|
|
*/ |
|
31
|
|
|
private $assignRoleTask; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* CreateUserAction constructor. |
|
35
|
|
|
* |
|
36
|
|
|
* @param \App\Containers\User\Tasks\CreateUserByCredentialsTask $createUserByCredentialsTask |
|
37
|
|
|
* @param \App\Containers\User\Tasks\FireUserCreatedEventTask $fireUserCreatedEventTask |
|
38
|
|
|
* @param \App\Containers\Authorization\Tasks\AssignRoleTask $assignRoleTask |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct( |
|
41
|
|
|
CreateUserByCredentialsTask $createUserByCredentialsTask, |
|
42
|
|
|
FireUserCreatedEventTask $fireUserCreatedEventTask, |
|
43
|
|
|
AssignRoleTask $assignRoleTask |
|
44
|
|
|
) { |
|
45
|
|
|
$this->createUserByCredentialsTask = $createUserByCredentialsTask; |
|
|
|
|
|
|
46
|
|
|
$this->fireUserCreatedEventTask = $fireUserCreatedEventTask; |
|
|
|
|
|
|
47
|
|
|
$this->assignRoleTask = $assignRoleTask; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param $email |
|
52
|
|
|
* @param $password |
|
53
|
|
|
* @param $name |
|
54
|
|
|
* |
|
55
|
|
|
* @return mixed |
|
56
|
|
|
*/ |
|
57
|
|
|
public function run($email, $password, $name) |
|
58
|
|
|
{ |
|
59
|
|
|
$admin = $this->createUserByCredentialsTask->run($email, $password, $name); |
|
60
|
|
|
|
|
61
|
|
|
$this->assignRoleTask->run($admin, ['admin']); |
|
62
|
|
|
|
|
63
|
|
|
return $admin; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..