1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Entity; |
4
|
|
|
|
5
|
|
|
use App\Entity\Attribute\Accessor as EntityAccessor; |
6
|
|
|
use DateTime; |
7
|
|
|
use Ds\Component\Model\Type\Deletable; |
|
|
|
|
8
|
|
|
use Ds\Component\Model\Type\Identifiable; |
|
|
|
|
9
|
|
|
use Ds\Component\Model\Type\Uuidentifiable; |
|
|
|
|
10
|
|
|
use Ds\Component\Model\Type\Ownable; |
|
|
|
|
11
|
|
|
use Ds\Component\Model\Type\Identitiable; |
|
|
|
|
12
|
|
|
use Ds\Component\Model\Type\Versionable; |
|
|
|
|
13
|
|
|
use Ds\Component\Model\Attribute\Accessor; |
|
|
|
|
14
|
|
|
use Ds\Component\Tenant\Model\Attribute\Accessor as TenantAccessor; |
|
|
|
|
15
|
|
|
use Ds\Component\Tenant\Model\Type\Tenantable; |
|
|
|
|
16
|
|
|
use FOS\UserBundle\Model\User as BaseUser; |
|
|
|
|
17
|
|
|
use FOS\UserBundle\Model\UserInterface; |
|
|
|
|
18
|
|
|
use Knp\DoctrineBehaviors\Model as Behavior; |
|
|
|
|
19
|
|
|
|
20
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
|
|
|
|
21
|
|
|
use ApiPlatform\Core\Annotation\ApiProperty; |
|
|
|
|
22
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
23
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints as ORMAssert; |
|
|
|
|
24
|
|
|
use Symfony\Component\Serializer\Annotation As Serializer; |
|
|
|
|
25
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @ApiResource( |
29
|
|
|
* attributes={ |
30
|
|
|
* "normalization_context"={ |
31
|
|
|
* "groups"={"user_output"} |
32
|
|
|
* }, |
33
|
|
|
* "denormalization_context"={ |
34
|
|
|
* "groups"={"user_input"} |
35
|
|
|
* }, |
36
|
|
|
* "filters"={ |
37
|
|
|
* "app.user.search", |
38
|
|
|
* "app.user.date", |
39
|
|
|
* "app.user.boolean", |
40
|
|
|
* "app.user.order" |
41
|
|
|
* } |
42
|
|
|
* } |
43
|
|
|
* ) |
44
|
|
|
* @ORM\Entity |
45
|
|
|
* @ORM\Table( |
46
|
|
|
* name="app_user", |
47
|
|
|
* uniqueConstraints={ |
48
|
|
|
* @ORM\UniqueConstraint(columns={"username", "tenant"}), |
49
|
|
|
* @ORM\UniqueConstraint(columns={"username_canonical", "tenant"}), |
50
|
|
|
* @ORM\UniqueConstraint(columns={"email", "tenant"}), |
51
|
|
|
* @ORM\UniqueConstraint(columns={"email_canonical", "tenant"}) |
52
|
|
|
* } |
53
|
|
|
* ) |
54
|
|
|
* @ORM\AttributeOverrides({ |
55
|
|
|
* @ORM\AttributeOverride( |
56
|
|
|
* name="usernameCanonical", |
57
|
|
|
* column=@ORM\Column(type="string", name="username_canonical", length=180, unique=false) |
58
|
|
|
* ), |
59
|
|
|
* @ORM\AttributeOverride( |
60
|
|
|
* name="emailCanonical", |
61
|
|
|
* column=@ORM\Column(type="string", name="email_canonical", length=180, unique=false) |
62
|
|
|
* ) |
63
|
|
|
* }) |
64
|
|
|
* @ORM\Cache(usage="NONSTRICT_READ_WRITE") |
65
|
|
|
* @ORMAssert\UniqueEntity(fields="uuid") |
66
|
|
|
* @ORMAssert\UniqueEntity(fields={"username", "tenant"}) |
67
|
|
|
* @ORMAssert\UniqueEntity(fields={"usernameCanonical", "tenant"}) |
68
|
|
|
* @ORMAssert\UniqueEntity(fields={"email", "tenant"}) |
69
|
|
|
* @ORMAssert\UniqueEntity(fields={"emailCanonical", "tenant"}) |
70
|
|
|
*/ |
71
|
|
|
class User extends BaseUser implements Identifiable, Uuidentifiable, Ownable, Identitiable, Deletable, Versionable, Tenantable |
72
|
|
|
{ |
73
|
|
|
use Behavior\Timestampable\Timestampable; |
|
|
|
|
74
|
|
|
use Behavior\SoftDeletable\SoftDeletable; |
|
|
|
|
75
|
|
|
|
76
|
|
|
use Accessor\Id; |
|
|
|
|
77
|
|
|
use Accessor\Uuid; |
|
|
|
|
78
|
|
|
use Accessor\Owner; |
|
|
|
|
79
|
|
|
use Accessor\OwnerUuid; |
|
|
|
|
80
|
|
|
use Accessor\Identity; |
|
|
|
|
81
|
|
|
use Accessor\IdentityUuid; |
|
|
|
|
82
|
|
|
use EntityAccessor\Registration; |
83
|
|
|
use Accessor\Deleted; |
|
|
|
|
84
|
|
|
use Accessor\Version; |
|
|
|
|
85
|
|
|
use TenantAccessor\Tenant; |
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @var integer |
89
|
|
|
* @ApiProperty(identifier=false, writable=false) |
90
|
|
|
* @Serializer\Groups({"user_output"}) |
91
|
|
|
* @ORM\Id |
92
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
93
|
|
|
* @ORM\Column(name="id", type="integer") |
94
|
|
|
*/ |
95
|
|
|
protected $id; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @var string |
99
|
|
|
* @ApiProperty(identifier=true, writable=false) |
100
|
|
|
* @Serializer\Groups({"user_output"}) |
101
|
|
|
* @ORM\Column(name="uuid", type="guid", unique=true) |
102
|
|
|
* @Assert\Uuid |
103
|
|
|
*/ |
104
|
|
|
private $uuid; |
|
|
|
|
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @var \DateTime |
108
|
|
|
* @ApiProperty(writable=false) |
109
|
|
|
* @Serializer\Groups({"user_output"}) |
110
|
|
|
*/ |
111
|
|
|
protected $createdAt; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @var \DateTime |
115
|
|
|
* @ApiProperty(writable=false) |
116
|
|
|
* @Serializer\Groups({"user_output"}) |
117
|
|
|
*/ |
118
|
|
|
protected $updatedAt; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @var \DateTime |
122
|
|
|
* @ApiProperty(writable=false) |
123
|
|
|
* @Serializer\Groups({"user_output"}) |
124
|
|
|
*/ |
125
|
|
|
protected $deletedAt; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @var string |
129
|
|
|
* @ApiProperty |
130
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
131
|
|
|
* @Assert\NotBlank |
132
|
|
|
* @Assert\Length(min=1, max=255) |
133
|
|
|
*/ |
134
|
|
|
protected $username; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @var string |
138
|
|
|
* @ApiProperty(readable=false) |
139
|
|
|
* @Serializer\Groups({"user_input"}) |
140
|
|
|
*/ |
141
|
|
|
protected $plainPassword; |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @var string |
145
|
|
|
* @ApiProperty |
146
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
147
|
|
|
* @Assert\NotBlank |
148
|
|
|
* @Assert\Length(min=1, max=255) |
149
|
|
|
* @Assert\Regex("/^.+@.+$/") |
150
|
|
|
*/ |
151
|
|
|
protected $email; |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @var boolean |
155
|
|
|
* @ApiProperty |
156
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
157
|
|
|
* @Assert\Type("boolean") |
158
|
|
|
*/ |
159
|
|
|
protected $enabled; |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @var \DateTime |
163
|
|
|
*/ |
164
|
|
|
protected $lastLogin; # region accessors |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* {@inheritdoc} |
168
|
|
|
*/ |
169
|
|
|
public function setLastLogin(DateTime $time = null) |
170
|
|
|
{ |
171
|
|
|
// Disable last login by always setting it to null. This avoids a version bump due to login in. |
172
|
|
|
$this->lastLogin = null; |
173
|
|
|
|
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
# endregion |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @var \Doctrine\Common\Collections\Collection |
|
|
|
|
181
|
|
|
* @ApiProperty |
182
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
183
|
|
|
*/ |
184
|
|
|
protected $groups; |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @var array |
188
|
|
|
* @ApiProperty |
189
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
190
|
|
|
* @Assert\Type("array") |
191
|
|
|
* @Assert\All({ |
192
|
|
|
* @Assert\NotBlank, |
193
|
|
|
* @Assert\Length(min=1) |
194
|
|
|
* }) |
195
|
|
|
*/ |
196
|
|
|
protected $roles; |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @var string |
200
|
|
|
* @ApiProperty |
201
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
202
|
|
|
* @ORM\Column(name="`owner`", type="string", length=255, nullable=true) |
203
|
|
|
* @Assert\NotBlank |
204
|
|
|
* @Assert\Length(min=1, max=255) |
205
|
|
|
*/ |
206
|
|
|
private $owner; |
|
|
|
|
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @var string |
210
|
|
|
* @ApiProperty |
211
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
212
|
|
|
* @ORM\Column(name="owner_uuid", type="guid", nullable=true) |
213
|
|
|
* @Assert\NotBlank |
214
|
|
|
* @Assert\Uuid |
215
|
|
|
*/ |
216
|
|
|
private $ownerUuid; |
|
|
|
|
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @var string |
220
|
|
|
* @ApiProperty |
221
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
222
|
|
|
* @ORM\Column(name="identity", type="string", length=255, nullable=true) |
223
|
|
|
* @Assert\NotBlank |
224
|
|
|
* @Assert\Length(min=1, max=255) |
225
|
|
|
*/ |
226
|
|
|
private $identity; |
|
|
|
|
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @var string |
230
|
|
|
* @ApiProperty |
231
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
232
|
|
|
* @ORM\Column(name="identity_uuid", type="guid", nullable=true) |
233
|
|
|
* @Assert\Uuid |
234
|
|
|
*/ |
235
|
|
|
private $identityUuid; |
|
|
|
|
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @var \App\Entity\Registration |
239
|
|
|
* @ORM\OneToOne(targetEntity="Registration", mappedBy="user") |
240
|
|
|
* @ORM\Cache(usage="NONSTRICT_READ_WRITE") |
241
|
|
|
*/ |
242
|
|
|
private $registration; |
|
|
|
|
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @var integer |
246
|
|
|
* @ApiProperty |
247
|
|
|
* @Serializer\Groups({"user_output", "user_input"}) |
248
|
|
|
* @ORM\Column(name="version", type="integer") |
249
|
|
|
* @ORM\Version |
250
|
|
|
* @Assert\NotBlank |
251
|
|
|
* @Assert\Type("integer") |
252
|
|
|
*/ |
253
|
|
|
private $version; |
|
|
|
|
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @var string |
257
|
|
|
* @ApiProperty(writable=false) |
258
|
|
|
* @Serializer\Groups({"user_output"}) |
259
|
|
|
* @ORM\Column(name="tenant", type="guid") |
260
|
|
|
* @Assert\Uuid |
261
|
|
|
*/ |
262
|
|
|
private $tenant; |
|
|
|
|
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Check if user is user |
266
|
|
|
* |
267
|
|
|
* @param \FOS\UserBundle\Model\UserInterface $user |
268
|
|
|
* @return boolean |
269
|
|
|
*/ |
270
|
|
|
public function isUser(UserInterface $user = null) |
271
|
|
|
{ |
272
|
|
|
return $user instanceof self && $user->id === $this->id; |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths