|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
namespace Xervice\User; |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
use Xervice\Core\Factory\AbstractFactory; |
|
9
|
|
|
use Xervice\Session\SessionClient; |
|
10
|
|
|
use Xervice\User\Business\Authenticator\AuthProvider; |
|
11
|
|
|
use Xervice\User\Business\Authenticator\AuthProviderInterface; |
|
12
|
|
|
use Xervice\User\Business\Authenticator\UserCredentialProvider; |
|
13
|
|
|
use Xervice\User\Business\Authenticator\UserCredentialProviderInterface; |
|
14
|
|
|
use Xervice\User\Business\Login\LoginHandler; |
|
15
|
|
|
use Xervice\User\Business\Login\LoginHandlerInterface; |
|
16
|
|
|
use Xervice\User\Business\Validator\UserValidator; |
|
17
|
|
|
use Xervice\User\Business\Validator\UserValidatorInterface; |
|
18
|
|
|
use Xervice\User\Business\Writer\CredentialWriter; |
|
19
|
|
|
use Xervice\User\Business\Writer\CredentialWriterInterface; |
|
20
|
|
|
use Xervice\User\Business\Writer\LoginWriter; |
|
21
|
|
|
use Xervice\User\Business\Writer\LoginWriterInterface; |
|
22
|
|
|
use Xervice\User\Business\Writer\UserWriter; |
|
23
|
|
|
use Xervice\User\Business\Writer\UserWriterInterface; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @method \Xervice\User\UserConfig getConfig() |
|
27
|
|
|
*/ |
|
28
|
|
|
class UserFactory extends AbstractFactory |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @return \Xervice\User\Business\Writer\CredentialWriterInterface |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public function createCredentialWriter(): CredentialWriterInterface |
|
34
|
|
|
{ |
|
35
|
1 |
|
return new CredentialWriter( |
|
36
|
1 |
|
$this->getQueryContainer() |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @return \Xervice\User\Business\Writer\LoginWriterInterface |
|
42
|
|
|
*/ |
|
43
|
1 |
|
public function createLoginWriter(): LoginWriterInterface |
|
44
|
|
|
{ |
|
45
|
1 |
|
return new LoginWriter( |
|
46
|
1 |
|
$this->getQueryContainer() |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return \Xervice\User\Business\Login\LoginHandlerInterface |
|
52
|
|
|
*/ |
|
53
|
|
|
public function createLoginHandler(): LoginHandlerInterface |
|
54
|
|
|
{ |
|
55
|
|
|
return new LoginHandler( |
|
56
|
|
|
$this->getSessionClient(), |
|
57
|
|
|
$this->createAuthProvider() |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return \Xervice\User\Business\Authenticator\AuthProviderInterface |
|
63
|
|
|
*/ |
|
64
|
1 |
|
public function createAuthProvider(): AuthProviderInterface |
|
65
|
|
|
{ |
|
66
|
1 |
|
return new AuthProvider( |
|
67
|
1 |
|
$this->createCredentialProvider(), |
|
68
|
1 |
|
$this->getLoginPluginList() |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return \Xervice\User\Business\Authenticator\UserCredentialProviderInterface |
|
74
|
|
|
*/ |
|
75
|
1 |
|
public function createCredentialProvider(): UserCredentialProviderInterface |
|
76
|
|
|
{ |
|
77
|
1 |
|
return new UserCredentialProvider( |
|
78
|
1 |
|
$this->getQueryContainer() |
|
79
|
|
|
); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return \Xervice\User\Business\Writer\UserWriterInterface |
|
84
|
|
|
*/ |
|
85
|
5 |
|
public function createUserWriter(): UserWriterInterface |
|
86
|
|
|
{ |
|
87
|
5 |
|
return new UserWriter( |
|
88
|
5 |
|
$this->createUserValidator(), |
|
89
|
5 |
|
$this->getQueryContainer() |
|
90
|
|
|
); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return \Xervice\User\Business\Validator\UserValidatorInterface |
|
95
|
|
|
*/ |
|
96
|
5 |
|
public function createUserValidator(): UserValidatorInterface |
|
97
|
|
|
{ |
|
98
|
5 |
|
return new UserValidator( |
|
99
|
5 |
|
$this->getQueryContainer() |
|
100
|
|
|
); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return array |
|
105
|
|
|
*/ |
|
106
|
1 |
|
public function getLoginPluginList(): array |
|
107
|
|
|
{ |
|
108
|
1 |
|
return $this->getDependency(UserDependencyProvider::LOGIN_PLUGINS); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @return \Xervice\User\UserQueryContainerInterface |
|
113
|
|
|
*/ |
|
114
|
5 |
|
public function getQueryContainer(): UserQueryContainerInterface |
|
115
|
|
|
{ |
|
116
|
5 |
|
return $this->getDependency(UserDependencyProvider::QUERY_CONTAINER); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @return \Xervice\Session\SessionClient |
|
121
|
|
|
*/ |
|
122
|
|
|
public function getSessionClient(): SessionClient |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->getDependency(UserDependencyProvider::SESSION_CLIENT); |
|
125
|
|
|
} |
|
126
|
|
|
} |