| Total Complexity | 184 |
| Total Lines | 2222 |
| Duplicated Lines | 0 % |
| Changes | 6 | ||
| Bugs | 3 | Features | 0 |
Complex classes like User often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use User, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 55 | class User implements UserInterface, EquatableInterface |
||
| 56 | { |
||
| 57 | public const ROLE_DEFAULT = 'ROLE_USER'; |
||
| 58 | public const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN'; |
||
| 59 | |||
| 60 | public const COURSE_MANAGER = 1; |
||
| 61 | public const TEACHER = 1; |
||
| 62 | public const SESSION_ADMIN = 3; |
||
| 63 | public const DRH = 4; |
||
| 64 | public const STUDENT = 5; |
||
| 65 | public const ANONYMOUS = 6; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var int |
||
| 69 | * @Groups({"user:read", "resource_node:read"}) |
||
| 70 | * @ORM\Column(name="id", type="integer") |
||
| 71 | * @ORM\Id |
||
| 72 | * @ORM\GeneratedValue(strategy="AUTO") |
||
| 73 | */ |
||
| 74 | protected $id; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @var UuidInterface|null |
||
| 78 | * |
||
| 79 | * @ORM\Column(type="uuid", unique=true) |
||
| 80 | */ |
||
| 81 | protected $uuid; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @ORM\Column(type="string", unique=true, nullable=true) |
||
| 85 | */ |
||
| 86 | protected $apiToken; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var string |
||
| 90 | * @Assert\NotBlank() |
||
| 91 | * @ApiProperty(iri="http://schema.org/name") |
||
| 92 | * @Groups({"user:read", "user:write", "resource_node:read"}) |
||
| 93 | * @ORM\Column(name="firstname", type="string", length=64, nullable=true, unique=false) |
||
| 94 | */ |
||
| 95 | protected $firstname; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @var string |
||
| 99 | * @Groups({"user:read", "user:write", "resource_node:read"}) |
||
| 100 | * @ORM\Column(name="lastname", type="string", length=64, nullable=true, unique=false) |
||
| 101 | */ |
||
| 102 | protected $lastname; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var string |
||
| 106 | * @Groups({"user:read", "user:write"}) |
||
| 107 | * @ORM\Column(name="website", type="string", length=64, nullable=true) |
||
| 108 | */ |
||
| 109 | protected $website; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @var string |
||
| 113 | * @Groups({"user:read", "user:write"}) |
||
| 114 | * @ORM\Column(name="biography", type="text", nullable=true) |
||
| 115 | */ |
||
| 116 | protected $biography; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @var string |
||
| 120 | * @Groups({"user:read", "user:write"}) |
||
| 121 | * @ORM\Column(name="locale", type="string", length=8, nullable=true, unique=false) |
||
| 122 | */ |
||
| 123 | protected $locale; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @var string |
||
| 127 | * @Groups({"user:read", "user:write", "course:read", "resource_node:read"}) |
||
| 128 | * @Assert\NotBlank() |
||
| 129 | * @ORM\Column(name="username", type="string", length=100, nullable=false, unique=true) |
||
| 130 | */ |
||
| 131 | protected $username; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @var string|null |
||
| 135 | */ |
||
| 136 | protected $plainPassword; |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @var string |
||
| 140 | * @ORM\Column(name="password", type="string", length=255, nullable=false, unique=false) |
||
| 141 | */ |
||
| 142 | protected $password; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @var string |
||
| 146 | * |
||
| 147 | * @ORM\Column(name="username_canonical", type="string", length=180, nullable=false) |
||
| 148 | */ |
||
| 149 | protected $usernameCanonical; |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @var string |
||
| 153 | * @Groups({"user:read", "user:write"}) |
||
| 154 | * @ORM\Column(name="timezone", type="string", length=64) |
||
| 155 | */ |
||
| 156 | protected $timezone; |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @var string |
||
| 160 | * @ORM\Column(name="email_canonical", type="string", length=100, nullable=false, unique=false) |
||
| 161 | */ |
||
| 162 | protected $emailCanonical; |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @var string |
||
| 166 | * @var string |
||
| 167 | * @Groups({"user:read", "user:write"}) |
||
| 168 | * @Assert\NotBlank() |
||
| 169 | * @Assert\Email() |
||
| 170 | * |
||
| 171 | * @ORM\Column(name="email", type="string", length=100, nullable=false, unique=false) |
||
| 172 | */ |
||
| 173 | protected $email; |
||
| 174 | |||
| 175 | /** |
||
| 176 | * @var bool |
||
| 177 | * |
||
| 178 | * @ORM\Column(name="locked", type="boolean") |
||
| 179 | */ |
||
| 180 | protected $locked; |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @var bool |
||
| 184 | * @Assert\NotBlank() |
||
| 185 | * @Groups({"user:read", "user:write"}) |
||
| 186 | * @ORM\Column(name="enabled", type="boolean") |
||
| 187 | */ |
||
| 188 | protected $enabled; |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @var bool |
||
| 192 | * @Groups({"user:read", "user:write"}) |
||
| 193 | * @ORM\Column(name="expired", type="boolean") |
||
| 194 | */ |
||
| 195 | protected $expired; |
||
| 196 | |||
| 197 | /** |
||
| 198 | * @var bool |
||
| 199 | * |
||
| 200 | * @ORM\Column(name="credentials_expired", type="boolean") |
||
| 201 | */ |
||
| 202 | protected $credentialsExpired; |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @var \DateTime |
||
| 206 | * |
||
| 207 | * @ORM\Column(name="credentials_expire_at", type="datetime", nullable=true, unique=false) |
||
| 208 | */ |
||
| 209 | protected $credentialsExpireAt; |
||
| 210 | |||
| 211 | /** |
||
| 212 | * @var \DateTime |
||
| 213 | * |
||
| 214 | * @ORM\Column(name="date_of_birth", type="datetime", nullable=true) |
||
| 215 | */ |
||
| 216 | protected $dateOfBirth; |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @var \DateTime |
||
| 220 | * @Groups({"user:read", "user:write"}) |
||
| 221 | * @ORM\Column(name="expires_at", type="datetime", nullable=true, unique=false) |
||
| 222 | */ |
||
| 223 | protected $expiresAt; |
||
| 224 | |||
| 225 | /** |
||
| 226 | * @var string |
||
| 227 | * @Groups({"user:read", "user:write"}) |
||
| 228 | * @ORM\Column(name="phone", type="string", length=64, nullable=true, unique=false) |
||
| 229 | */ |
||
| 230 | protected $phone; |
||
| 231 | |||
| 232 | /** |
||
| 233 | * @var string |
||
| 234 | * @Groups({"user:read", "user:write"}) |
||
| 235 | * @ORM\Column(name="address", type="string", length=250, nullable=true, unique=false) |
||
| 236 | */ |
||
| 237 | protected $address; |
||
| 238 | |||
| 239 | /** |
||
| 240 | * @var AccessUrl |
||
| 241 | */ |
||
| 242 | protected $currentUrl; |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @ORM\Column(type="string", length=255) |
||
| 246 | */ |
||
| 247 | protected $salt; |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @var \DateTime |
||
| 251 | * @Groups({"user:read", "user:write"}) |
||
| 252 | * @ORM\Column(name="last_login", type="datetime", nullable=true, unique=false) |
||
| 253 | */ |
||
| 254 | protected $lastLogin; |
||
| 255 | |||
| 256 | /** |
||
| 257 | * Random string sent to the user email address in order to verify it. |
||
| 258 | * |
||
| 259 | * @var string |
||
| 260 | * @ORM\Column(name="confirmation_token", type="string", length=255, nullable=true) |
||
| 261 | */ |
||
| 262 | protected $confirmationToken; |
||
| 263 | |||
| 264 | /** |
||
| 265 | * @var \DateTime |
||
| 266 | * |
||
| 267 | * @ORM\Column(name="password_requested_at", type="datetime", nullable=true, unique=false) |
||
| 268 | */ |
||
| 269 | protected $passwordRequestedAt; |
||
| 270 | |||
| 271 | /** |
||
| 272 | * @ApiSubresource() |
||
| 273 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user", orphanRemoval=true) |
||
| 274 | */ |
||
| 275 | protected $courses; |
||
| 276 | |||
| 277 | /** |
||
| 278 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UsergroupRelUser", mappedBy="user") |
||
| 279 | */ |
||
| 280 | protected $classes; |
||
| 281 | |||
| 282 | /** |
||
| 283 | * ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxPost", mappedBy="user"). |
||
| 284 | */ |
||
| 285 | protected $dropBoxReceivedFiles; |
||
| 286 | |||
| 287 | /** |
||
| 288 | * ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxFile", mappedBy="userSent"). |
||
| 289 | */ |
||
| 290 | protected $dropBoxSentFiles; |
||
| 291 | |||
| 292 | /** |
||
| 293 | * @Groups({"user:read", "user:write"}) |
||
| 294 | * @ORM\Column(type="array") |
||
| 295 | */ |
||
| 296 | protected $roles; |
||
| 297 | |||
| 298 | /** |
||
| 299 | * @var bool |
||
| 300 | * |
||
| 301 | * @ORM\Column(name="profile_completed", type="boolean", nullable=true) |
||
| 302 | */ |
||
| 303 | protected $profileCompleted; |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user") |
||
| 307 | */ |
||
| 308 | //protected $jurySubscriptions; |
||
| 309 | |||
| 310 | /** |
||
| 311 | * @var Group[] |
||
| 312 | * @ORM\ManyToMany(targetEntity="Chamilo\CoreBundle\Entity\Group", inversedBy="users") |
||
| 313 | * @ORM\JoinTable( |
||
| 314 | * name="fos_user_user_group", |
||
| 315 | * joinColumns={ |
||
| 316 | * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="cascade") |
||
| 317 | * }, |
||
| 318 | * inverseJoinColumns={ |
||
| 319 | * @ORM\JoinColumn(name="group_id", referencedColumnName="id") |
||
| 320 | * } |
||
| 321 | * ) |
||
| 322 | */ |
||
| 323 | protected $groups; |
||
| 324 | |||
| 325 | /** |
||
| 326 | * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CurriculumItemRelUser", mappedBy="user"). |
||
| 327 | */ |
||
| 328 | protected $curriculumItems; |
||
| 329 | |||
| 330 | /** |
||
| 331 | * @ORM\OneToMany( |
||
| 332 | * targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelUser", |
||
| 333 | * mappedBy="user", |
||
| 334 | * cascade={"persist", "remove"}, |
||
| 335 | * orphanRemoval=true |
||
| 336 | * ) |
||
| 337 | */ |
||
| 338 | protected $portals; |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @var ArrayCollection |
||
| 342 | * |
||
| 343 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="generalCoach") |
||
| 344 | */ |
||
| 345 | protected $sessionAsGeneralCoach; |
||
| 346 | |||
| 347 | /** |
||
| 348 | * @ORM\OneToOne( |
||
| 349 | * targetEntity="Chamilo\CoreBundle\Entity\ResourceNode", cascade={"remove"}, orphanRemoval=true |
||
| 350 | * ) |
||
| 351 | * @ORM\JoinColumn(name="resource_node_id", referencedColumnName="id", onDelete="CASCADE") |
||
| 352 | */ |
||
| 353 | protected $resourceNode; |
||
| 354 | |||
| 355 | /** |
||
| 356 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\ResourceNode", mappedBy="creator") |
||
| 357 | */ |
||
| 358 | protected $resourceNodes; |
||
| 359 | |||
| 360 | /** |
||
| 361 | * @ApiSubresource() |
||
| 362 | * @ORM\OneToMany( |
||
| 363 | * targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", |
||
| 364 | * mappedBy="user", |
||
| 365 | * cascade={"persist"}, |
||
| 366 | * orphanRemoval=true |
||
| 367 | * ) |
||
| 368 | */ |
||
| 369 | protected $sessionCourseSubscriptions; |
||
| 370 | |||
| 371 | /** |
||
| 372 | * @ORM\OneToMany( |
||
| 373 | * targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", |
||
| 374 | * mappedBy="user", |
||
| 375 | * cascade={"persist", "remove"}, |
||
| 376 | * orphanRemoval=true |
||
| 377 | * ) |
||
| 378 | */ |
||
| 379 | protected $achievedSkills; |
||
| 380 | |||
| 381 | /** |
||
| 382 | * @ORM\OneToMany( |
||
| 383 | * targetEntity="Chamilo\CoreBundle\Entity\SkillRelUserComment", |
||
| 384 | * mappedBy="feedbackGiver", |
||
| 385 | * cascade={"persist", "remove"}, |
||
| 386 | * orphanRemoval=true |
||
| 387 | * ) |
||
| 388 | */ |
||
| 389 | protected $commentedUserSkills; |
||
| 390 | |||
| 391 | /** |
||
| 392 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\GradebookCategory", mappedBy="user") |
||
| 393 | */ |
||
| 394 | protected $gradeBookCategories; |
||
| 395 | |||
| 396 | /** |
||
| 397 | * @ORM\OneToMany( |
||
| 398 | * targetEntity="Chamilo\CoreBundle\Entity\SessionRelUser", |
||
| 399 | * mappedBy="user", |
||
| 400 | * cascade={"persist", "remove"}, |
||
| 401 | * orphanRemoval=true |
||
| 402 | * ) |
||
| 403 | */ |
||
| 404 | protected $sessions; |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @var Collection |
||
| 408 | * |
||
| 409 | * @ORM\OneToMany( |
||
| 410 | * targetEntity="Chamilo\CourseBundle\Entity\CGroupRelUser", |
||
| 411 | * mappedBy="user", |
||
| 412 | * cascade={"persist", "remove"}, |
||
| 413 | * orphanRemoval=true |
||
| 414 | * ) |
||
| 415 | */ |
||
| 416 | protected $courseGroupsAsMember; |
||
| 417 | |||
| 418 | /** |
||
| 419 | * @var Collection |
||
| 420 | * |
||
| 421 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CGroupRelTutor", mappedBy="user", orphanRemoval=true) |
||
| 422 | */ |
||
| 423 | protected $courseGroupsAsTutor; |
||
| 424 | |||
| 425 | /** |
||
| 426 | * @var string |
||
| 427 | * |
||
| 428 | * @ORM\Column(name="auth_source", type="string", length=50, nullable=true, unique=false) |
||
| 429 | */ |
||
| 430 | protected $authSource; |
||
| 431 | |||
| 432 | /** |
||
| 433 | * @var int |
||
| 434 | * |
||
| 435 | * @ORM\Column(name="status", type="integer", nullable=false) |
||
| 436 | */ |
||
| 437 | protected $status; |
||
| 438 | |||
| 439 | /** |
||
| 440 | * @var string |
||
| 441 | * |
||
| 442 | * @ORM\Column(name="official_code", type="string", length=40, nullable=true, unique=false) |
||
| 443 | */ |
||
| 444 | protected $officialCode; |
||
| 445 | |||
| 446 | /** |
||
| 447 | * @var string |
||
| 448 | * |
||
| 449 | * @ORM\Column(name="picture_uri", type="string", length=250, nullable=true, unique=false) |
||
| 450 | */ |
||
| 451 | protected $pictureUri; |
||
| 452 | |||
| 453 | /** |
||
| 454 | * @var int |
||
| 455 | * |
||
| 456 | * @ORM\Column(name="creator_id", type="integer", nullable=true, unique=false) |
||
| 457 | */ |
||
| 458 | protected $creatorId; |
||
| 459 | |||
| 460 | /** |
||
| 461 | * @var string |
||
| 462 | * |
||
| 463 | * @ORM\Column(name="competences", type="text", nullable=true, unique=false) |
||
| 464 | */ |
||
| 465 | protected $competences; |
||
| 466 | |||
| 467 | /** |
||
| 468 | * @var string |
||
| 469 | * |
||
| 470 | * @ORM\Column(name="diplomas", type="text", nullable=true, unique=false) |
||
| 471 | */ |
||
| 472 | protected $diplomas; |
||
| 473 | |||
| 474 | /** |
||
| 475 | * @var string |
||
| 476 | * |
||
| 477 | * @ORM\Column(name="openarea", type="text", nullable=true, unique=false) |
||
| 478 | */ |
||
| 479 | protected $openarea; |
||
| 480 | |||
| 481 | /** |
||
| 482 | * @var string |
||
| 483 | * |
||
| 484 | * @ORM\Column(name="teach", type="text", nullable=true, unique=false) |
||
| 485 | */ |
||
| 486 | protected $teach; |
||
| 487 | |||
| 488 | /** |
||
| 489 | * @var string |
||
| 490 | * |
||
| 491 | * @ORM\Column(name="productions", type="string", length=250, nullable=true, unique=false) |
||
| 492 | */ |
||
| 493 | protected $productions; |
||
| 494 | |||
| 495 | /** |
||
| 496 | * @var string |
||
| 497 | * |
||
| 498 | * @ORM\Column(name="language", type="string", length=40, nullable=true, unique=false) |
||
| 499 | */ |
||
| 500 | protected $language; |
||
| 501 | |||
| 502 | /** |
||
| 503 | * @var \DateTime |
||
| 504 | * |
||
| 505 | * @ORM\Column(name="registration_date", type="datetime", nullable=false, unique=false) |
||
| 506 | */ |
||
| 507 | protected $registrationDate; |
||
| 508 | |||
| 509 | /** |
||
| 510 | * @var \DateTime |
||
| 511 | * |
||
| 512 | * @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false) |
||
| 513 | */ |
||
| 514 | protected $expirationDate; |
||
| 515 | |||
| 516 | /** |
||
| 517 | * @var bool |
||
| 518 | * |
||
| 519 | * @ORM\Column(name="active", type="boolean", nullable=false, unique=false) |
||
| 520 | */ |
||
| 521 | protected $active; |
||
| 522 | |||
| 523 | /** |
||
| 524 | * @var string |
||
| 525 | * |
||
| 526 | * @ORM\Column(name="openid", type="string", length=255, nullable=true, unique=false) |
||
| 527 | */ |
||
| 528 | protected $openid; |
||
| 529 | |||
| 530 | /** |
||
| 531 | * @var string |
||
| 532 | * |
||
| 533 | * @ORM\Column(name="theme", type="string", length=255, nullable=true, unique=false) |
||
| 534 | */ |
||
| 535 | protected $theme; |
||
| 536 | |||
| 537 | /** |
||
| 538 | * @var int |
||
| 539 | * |
||
| 540 | * @ORM\Column(name="hr_dept_id", type="smallint", nullable=true, unique=false) |
||
| 541 | */ |
||
| 542 | protected $hrDeptId; |
||
| 543 | |||
| 544 | /** |
||
| 545 | * @var ArrayCollection |
||
| 546 | * |
||
| 547 | * @ORM\OneToMany( |
||
| 548 | * targetEntity="Chamilo\CoreBundle\Entity\Message", |
||
| 549 | * mappedBy="userSender", |
||
| 550 | * cascade={"persist", "remove"}, |
||
| 551 | * orphanRemoval=true |
||
| 552 | * ) |
||
| 553 | */ |
||
| 554 | protected $sentMessages; |
||
| 555 | |||
| 556 | /** |
||
| 557 | * @var ArrayCollection |
||
| 558 | * |
||
| 559 | * @ORM\OneToMany( |
||
| 560 | * targetEntity="Chamilo\CoreBundle\Entity\Message", |
||
| 561 | * mappedBy="userReceiver", |
||
| 562 | * cascade={"persist", "remove"}, |
||
| 563 | * orphanRemoval=true |
||
| 564 | * ) |
||
| 565 | */ |
||
| 566 | protected $receivedMessages; |
||
| 567 | |||
| 568 | /** |
||
| 569 | * @var \DateTime |
||
| 570 | * @ORM\Column(name="created_at", type="datetime", nullable=true, unique=false) |
||
| 571 | */ |
||
| 572 | protected $createdAt; |
||
| 573 | |||
| 574 | /** |
||
| 575 | * @var \DateTime |
||
| 576 | * @ORM\Column(name="updated_at", type="datetime", nullable=true, unique=false) |
||
| 577 | */ |
||
| 578 | protected $updatedAt; |
||
| 579 | |||
| 580 | /** |
||
| 581 | * Constructor. |
||
| 582 | */ |
||
| 583 | public function __construct() |
||
| 584 | { |
||
| 585 | $this->uuid = Uuid::uuid4()->toString(); |
||
| 586 | $this->status = self::STUDENT; |
||
| 587 | $this->salt = sha1(uniqid(null, true)); |
||
| 588 | $this->active = true; |
||
| 589 | $this->registrationDate = new \DateTime(); |
||
| 590 | $this->authSource = 'platform'; |
||
| 591 | $this->courses = new ArrayCollection(); |
||
| 592 | //$this->items = new ArrayCollection(); |
||
| 593 | $this->classes = new ArrayCollection(); |
||
| 594 | $this->curriculumItems = new ArrayCollection(); |
||
| 595 | $this->portals = new ArrayCollection(); |
||
| 596 | $this->dropBoxSentFiles = new ArrayCollection(); |
||
| 597 | $this->dropBoxReceivedFiles = new ArrayCollection(); |
||
| 598 | $this->groups = new ArrayCollection(); |
||
|
|
|||
| 599 | //$this->extraFields = new ArrayCollection(); |
||
| 600 | $this->createdAt = new \DateTime(); |
||
| 601 | $this->updatedAt = new \DateTime(); |
||
| 602 | |||
| 603 | $this->enabled = false; |
||
| 604 | $this->locked = false; |
||
| 605 | $this->expired = false; |
||
| 606 | $this->roles = []; |
||
| 607 | $this->credentialsExpired = false; |
||
| 608 | |||
| 609 | $this->courseGroupsAsMember = new ArrayCollection(); |
||
| 610 | $this->courseGroupsAsTutor = new ArrayCollection(); |
||
| 611 | } |
||
| 612 | |||
| 613 | /** |
||
| 614 | * @return int |
||
| 615 | */ |
||
| 616 | public function getId() |
||
| 617 | { |
||
| 618 | return $this->id; |
||
| 619 | } |
||
| 620 | |||
| 621 | /** |
||
| 622 | * @param int $userId |
||
| 623 | */ |
||
| 624 | public function setId($userId) |
||
| 625 | { |
||
| 626 | $this->id = $userId; |
||
| 627 | } |
||
| 628 | |||
| 629 | public function getUuid(): UuidInterface |
||
| 632 | } |
||
| 633 | |||
| 634 | /** |
||
| 635 | * @return string |
||
| 636 | */ |
||
| 637 | public function __toString() |
||
| 640 | } |
||
| 641 | |||
| 642 | public function setResourceNode(ResourceNode $resourceNode): self |
||
| 643 | { |
||
| 644 | $this->resourceNode = $resourceNode; |
||
| 645 | |||
| 646 | return $this; |
||
| 647 | } |
||
| 648 | |||
| 649 | public function getResourceNode(): ResourceNode |
||
| 650 | { |
||
| 651 | return $this->resourceNode; |
||
| 652 | } |
||
| 653 | |||
| 654 | /** |
||
| 655 | * @return ArrayCollection|ResourceNode[] |
||
| 656 | */ |
||
| 657 | public function getResourceNodes() |
||
| 658 | { |
||
| 659 | return $this->resourceNodes; |
||
| 660 | } |
||
| 661 | |||
| 662 | /** |
||
| 663 | * @return User |
||
| 664 | */ |
||
| 665 | public function setResourceNodes($resourceNodes) |
||
| 666 | { |
||
| 667 | $this->resourceNodes = $resourceNodes; |
||
| 668 | |||
| 669 | return $this; |
||
| 670 | } |
||
| 671 | |||
| 672 | /** |
||
| 673 | * @ORM\PostPersist() |
||
| 674 | */ |
||
| 675 | public function postPersist(LifecycleEventArgs $args) |
||
| 676 | { |
||
| 677 | /*$user = $args->getEntity(); |
||
| 678 | */ |
||
| 679 | } |
||
| 680 | |||
| 681 | /** |
||
| 682 | * @return ArrayCollection |
||
| 683 | */ |
||
| 684 | public function getDropBoxSentFiles() |
||
| 685 | { |
||
| 686 | return $this->dropBoxSentFiles; |
||
| 687 | } |
||
| 688 | |||
| 689 | /** |
||
| 690 | * @return ArrayCollection |
||
| 691 | */ |
||
| 692 | public function getDropBoxReceivedFiles() |
||
| 693 | { |
||
| 694 | return $this->dropBoxReceivedFiles; |
||
| 695 | } |
||
| 696 | |||
| 697 | /** |
||
| 698 | * @param ArrayCollection $value |
||
| 699 | */ |
||
| 700 | public function setDropBoxSentFiles($value) |
||
| 701 | { |
||
| 702 | $this->dropBoxSentFiles = $value; |
||
| 703 | } |
||
| 704 | |||
| 705 | /** |
||
| 706 | * @param ArrayCollection $value |
||
| 707 | */ |
||
| 708 | public function setDropBoxReceivedFiles($value) |
||
| 709 | { |
||
| 710 | $this->dropBoxReceivedFiles = $value; |
||
| 711 | } |
||
| 712 | |||
| 713 | /** |
||
| 714 | * @param ArrayCollection $courses |
||
| 715 | */ |
||
| 716 | public function setCourses($courses) |
||
| 717 | { |
||
| 718 | $this->courses = $courses; |
||
| 719 | } |
||
| 720 | |||
| 721 | public function getCourses(): Collection |
||
| 722 | { |
||
| 723 | return $this->courses; |
||
| 724 | } |
||
| 725 | |||
| 726 | /** |
||
| 727 | * @return array |
||
| 728 | */ |
||
| 729 | public static function getPasswordConstraints() |
||
| 730 | { |
||
| 731 | return |
||
| 732 | [ |
||
| 733 | new Assert\Length(['min' => 5]), |
||
| 734 | // Alpha numeric + "_" or "-" |
||
| 735 | new Assert\Regex( |
||
| 736 | [ |
||
| 737 | 'pattern' => '/^[a-z\-_0-9]+$/i', |
||
| 738 | 'htmlPattern' => '/^[a-z\-_0-9]+$/i', ] |
||
| 739 | ), |
||
| 740 | // Min 3 letters - not needed |
||
| 741 | /*new Assert\Regex(array( |
||
| 742 | 'pattern' => '/[a-z]{3}/i', |
||
| 743 | 'htmlPattern' => '/[a-z]{3}/i') |
||
| 744 | ),*/ |
||
| 745 | // Min 2 numbers |
||
| 746 | new Assert\Regex( |
||
| 747 | [ |
||
| 748 | 'pattern' => '/[0-9]{2}/', |
||
| 749 | 'htmlPattern' => '/[0-9]{2}/', ] |
||
| 750 | ), |
||
| 751 | ] |
||
| 752 | ; |
||
| 753 | } |
||
| 754 | |||
| 755 | public static function loadValidatorMetadata(ClassMetadata $metadata) |
||
| 756 | { |
||
| 757 | //$metadata->addPropertyConstraint('firstname', new Assert\NotBlank()); |
||
| 758 | //$metadata->addPropertyConstraint('lastname', new Assert\NotBlank()); |
||
| 759 | //$metadata->addPropertyConstraint('email', new Assert\Email()); |
||
| 760 | /* |
||
| 761 | $metadata->addPropertyConstraint('password', |
||
| 762 | new Assert\Collection(self::getPasswordConstraints()) |
||
| 763 | );*/ |
||
| 764 | |||
| 765 | /*$metadata->addConstraint(new UniqueEntity(array( |
||
| 766 | 'fields' => 'username', |
||
| 767 | 'message' => 'This value is already used.', |
||
| 768 | )));*/ |
||
| 769 | |||
| 770 | /*$metadata->addPropertyConstraint( |
||
| 771 | 'username', |
||
| 772 | new Assert\Length(array( |
||
| 773 | 'min' => 2, |
||
| 774 | 'max' => 50, |
||
| 775 | 'minMessage' => 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.', |
||
| 776 | 'maxMessage' => 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.', |
||
| 777 | )) |
||
| 778 | );*/ |
||
| 779 | } |
||
| 780 | |||
| 781 | /** |
||
| 782 | * @return ArrayCollection |
||
| 783 | */ |
||
| 784 | public function getPortals() |
||
| 785 | { |
||
| 786 | return $this->portals; |
||
| 787 | } |
||
| 788 | |||
| 789 | /** |
||
| 790 | * @param $portal |
||
| 791 | */ |
||
| 792 | public function setPortal($portal) |
||
| 793 | { |
||
| 794 | $this->portals->add($portal); |
||
| 795 | } |
||
| 796 | |||
| 797 | /** |
||
| 798 | * @param $value |
||
| 799 | * @param (mixed|string|string[])[] $value |
||
| 800 | */ |
||
| 801 | public function setPortals(array $value) |
||
| 802 | { |
||
| 803 | $this->portals = $value; |
||
| 804 | } |
||
| 805 | |||
| 806 | /** |
||
| 807 | * @return ArrayCollection |
||
| 808 | */ |
||
| 809 | public function getCurriculumItems() |
||
| 810 | { |
||
| 811 | return $this->curriculumItems; |
||
| 812 | } |
||
| 813 | |||
| 814 | /** |
||
| 815 | * @param $items |
||
| 816 | * |
||
| 817 | * @return $this |
||
| 818 | */ |
||
| 819 | public function setCurriculumItems(array $items) |
||
| 820 | { |
||
| 821 | $this->curriculumItems = $items; |
||
| 822 | |||
| 823 | return $this; |
||
| 824 | } |
||
| 825 | |||
| 826 | /** |
||
| 827 | * @return bool |
||
| 828 | */ |
||
| 829 | public function getIsActive() |
||
| 830 | { |
||
| 831 | return 1 == $this->active; |
||
| 832 | } |
||
| 833 | |||
| 834 | /** |
||
| 835 | * @return bool |
||
| 836 | */ |
||
| 837 | public function isActive() |
||
| 838 | { |
||
| 839 | return $this->getIsActive(); |
||
| 840 | } |
||
| 841 | |||
| 842 | public function isEnabled() |
||
| 843 | { |
||
| 844 | return 1 == $this->getActive(); |
||
| 845 | } |
||
| 846 | |||
| 847 | /** |
||
| 848 | * Set salt. |
||
| 849 | * |
||
| 850 | * @param string $salt |
||
| 851 | * |
||
| 852 | * @return User |
||
| 853 | */ |
||
| 854 | public function setSalt($salt) |
||
| 855 | { |
||
| 856 | $this->salt = $salt; |
||
| 857 | |||
| 858 | return $this; |
||
| 859 | } |
||
| 860 | |||
| 861 | /** |
||
| 862 | * Get salt. |
||
| 863 | * |
||
| 864 | * @return string |
||
| 865 | */ |
||
| 866 | public function getSalt() |
||
| 867 | { |
||
| 868 | return $this->salt; |
||
| 869 | } |
||
| 870 | |||
| 871 | /** |
||
| 872 | * @param ArrayCollection $classes |
||
| 873 | * |
||
| 874 | * @return $this |
||
| 875 | */ |
||
| 876 | public function setClasses($classes) |
||
| 877 | { |
||
| 878 | $this->classes = $classes; |
||
| 879 | |||
| 880 | return $this; |
||
| 881 | } |
||
| 882 | |||
| 883 | /** |
||
| 884 | * @return ArrayCollection |
||
| 885 | */ |
||
| 886 | public function getClasses() |
||
| 887 | { |
||
| 888 | return $this->classes; |
||
| 889 | } |
||
| 890 | |||
| 891 | public function getLps() |
||
| 892 | { |
||
| 893 | //return $this->lps; |
||
| 894 | /*$criteria = Criteria::create() |
||
| 895 | ->where(Criteria::expr()->eq("id", "666")) |
||
| 896 | //->orderBy(array("username" => "ASC")) |
||
| 897 | //->setFirstResult(0) |
||
| 898 | //->setMaxResults(20) |
||
| 899 | ; |
||
| 900 | $lps = $this->lps->matching($criteria);*/ |
||
| 901 | /*return $this->lps->filter( |
||
| 902 | function($entry) use ($idsToFilter) { |
||
| 903 | return $entry->getId() == 1; |
||
| 904 | });*/ |
||
| 905 | } |
||
| 906 | |||
| 907 | /** |
||
| 908 | * Returns the list of classes for the user. |
||
| 909 | * |
||
| 910 | * @return string |
||
| 911 | */ |
||
| 912 | public function getCompleteNameWithClasses() |
||
| 913 | { |
||
| 914 | $classSubscription = $this->getClasses(); |
||
| 915 | $classList = []; |
||
| 916 | /** @var UsergroupRelUser $subscription */ |
||
| 917 | foreach ($classSubscription as $subscription) { |
||
| 918 | $class = $subscription->getUsergroup(); |
||
| 919 | $classList[] = $class->getName(); |
||
| 920 | } |
||
| 921 | $classString = !empty($classList) ? ' ['.implode(', ', $classList).']' : null; |
||
| 922 | |||
| 923 | return \UserManager::formatUserFullName($this).$classString; |
||
| 924 | } |
||
| 925 | |||
| 926 | /** |
||
| 927 | * Set lastname. |
||
| 928 | * |
||
| 929 | * @return User |
||
| 930 | */ |
||
| 931 | public function setLastname(string $lastname): self |
||
| 932 | { |
||
| 933 | $this->lastname = $lastname; |
||
| 934 | |||
| 935 | return $this; |
||
| 936 | } |
||
| 937 | |||
| 938 | /** |
||
| 939 | * Set firstname. |
||
| 940 | * |
||
| 941 | * @return User |
||
| 942 | */ |
||
| 943 | public function setFirstname(string $firstname): self |
||
| 944 | { |
||
| 945 | $this->firstname = $firstname; |
||
| 946 | |||
| 947 | return $this; |
||
| 948 | } |
||
| 949 | |||
| 950 | public function getPassword() |
||
| 951 | { |
||
| 952 | return $this->password; |
||
| 953 | } |
||
| 954 | |||
| 955 | public function setPassword(string $password): self |
||
| 956 | { |
||
| 957 | $this->password = $password; |
||
| 958 | |||
| 959 | return $this; |
||
| 960 | } |
||
| 961 | |||
| 962 | /** |
||
| 963 | * Set authSource. |
||
| 964 | * |
||
| 965 | * @param string $authSource |
||
| 966 | * |
||
| 967 | * @return User |
||
| 968 | */ |
||
| 969 | public function setAuthSource($authSource) |
||
| 970 | { |
||
| 971 | $this->authSource = $authSource; |
||
| 972 | |||
| 973 | return $this; |
||
| 974 | } |
||
| 975 | |||
| 976 | /** |
||
| 977 | * Get authSource. |
||
| 978 | * |
||
| 979 | * @return string |
||
| 980 | */ |
||
| 981 | public function getAuthSource() |
||
| 982 | { |
||
| 983 | return $this->authSource; |
||
| 984 | } |
||
| 985 | |||
| 986 | /** |
||
| 987 | * Set email. |
||
| 988 | * |
||
| 989 | * @param string $email |
||
| 990 | * |
||
| 991 | * @return User |
||
| 992 | */ |
||
| 993 | public function setEmail($email) |
||
| 994 | { |
||
| 995 | $this->email = $email; |
||
| 996 | |||
| 997 | return $this; |
||
| 998 | } |
||
| 999 | |||
| 1000 | /** |
||
| 1001 | * Get email. |
||
| 1002 | * |
||
| 1003 | * @return string |
||
| 1004 | */ |
||
| 1005 | public function getEmail() |
||
| 1006 | { |
||
| 1007 | return $this->email; |
||
| 1008 | } |
||
| 1009 | |||
| 1010 | /** |
||
| 1011 | * Set status. |
||
| 1012 | * |
||
| 1013 | * @return User |
||
| 1014 | */ |
||
| 1015 | public function setStatus(int $status) |
||
| 1016 | { |
||
| 1017 | $this->status = $status; |
||
| 1018 | |||
| 1019 | return $this; |
||
| 1020 | } |
||
| 1021 | |||
| 1022 | /** |
||
| 1023 | * Get status. |
||
| 1024 | * |
||
| 1025 | * @return int |
||
| 1026 | */ |
||
| 1027 | public function getStatus() |
||
| 1028 | { |
||
| 1029 | return (int) $this->status; |
||
| 1030 | } |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Set officialCode. |
||
| 1034 | * |
||
| 1035 | * @param string $officialCode |
||
| 1036 | * |
||
| 1037 | * @return User |
||
| 1038 | */ |
||
| 1039 | public function setOfficialCode($officialCode) |
||
| 1040 | { |
||
| 1041 | $this->officialCode = $officialCode; |
||
| 1042 | |||
| 1043 | return $this; |
||
| 1044 | } |
||
| 1045 | |||
| 1046 | /** |
||
| 1047 | * Get officialCode. |
||
| 1048 | * |
||
| 1049 | * @return string |
||
| 1050 | */ |
||
| 1051 | public function getOfficialCode() |
||
| 1052 | { |
||
| 1053 | return $this->officialCode; |
||
| 1054 | } |
||
| 1055 | |||
| 1056 | /** |
||
| 1057 | * Set phone. |
||
| 1058 | * |
||
| 1059 | * @param string $phone |
||
| 1060 | * |
||
| 1061 | * @return User |
||
| 1062 | */ |
||
| 1063 | public function setPhone($phone) |
||
| 1064 | { |
||
| 1065 | $this->phone = $phone; |
||
| 1066 | |||
| 1067 | return $this; |
||
| 1068 | } |
||
| 1069 | |||
| 1070 | /** |
||
| 1071 | * Get phone. |
||
| 1072 | * |
||
| 1073 | * @return string |
||
| 1074 | */ |
||
| 1075 | public function getPhone() |
||
| 1076 | { |
||
| 1077 | return $this->phone; |
||
| 1078 | } |
||
| 1079 | |||
| 1080 | /** |
||
| 1081 | * Set address. |
||
| 1082 | * |
||
| 1083 | * @param string $address |
||
| 1084 | * |
||
| 1085 | * @return User |
||
| 1086 | */ |
||
| 1087 | public function setAddress($address) |
||
| 1088 | { |
||
| 1089 | $this->address = $address; |
||
| 1090 | |||
| 1091 | return $this; |
||
| 1092 | } |
||
| 1093 | |||
| 1094 | /** |
||
| 1095 | * Get address. |
||
| 1096 | * |
||
| 1097 | * @return string |
||
| 1098 | */ |
||
| 1099 | public function getAddress() |
||
| 1100 | { |
||
| 1101 | return $this->address; |
||
| 1102 | } |
||
| 1103 | |||
| 1104 | /** |
||
| 1105 | * Set creatorId. |
||
| 1106 | * |
||
| 1107 | * @param int $creatorId |
||
| 1108 | * |
||
| 1109 | * @return User |
||
| 1110 | */ |
||
| 1111 | public function setCreatorId($creatorId) |
||
| 1112 | { |
||
| 1113 | $this->creatorId = $creatorId; |
||
| 1114 | |||
| 1115 | return $this; |
||
| 1116 | } |
||
| 1117 | |||
| 1118 | /** |
||
| 1119 | * Get creatorId. |
||
| 1120 | * |
||
| 1121 | * @return int |
||
| 1122 | */ |
||
| 1123 | public function getCreatorId() |
||
| 1124 | { |
||
| 1125 | return $this->creatorId; |
||
| 1126 | } |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Set competences. |
||
| 1130 | * |
||
| 1131 | * @param string $competences |
||
| 1132 | * |
||
| 1133 | * @return User |
||
| 1134 | */ |
||
| 1135 | public function setCompetences($competences) |
||
| 1136 | { |
||
| 1137 | $this->competences = $competences; |
||
| 1138 | |||
| 1139 | return $this; |
||
| 1140 | } |
||
| 1141 | |||
| 1142 | /** |
||
| 1143 | * Get competences. |
||
| 1144 | * |
||
| 1145 | * @return string |
||
| 1146 | */ |
||
| 1147 | public function getCompetences() |
||
| 1148 | { |
||
| 1149 | return $this->competences; |
||
| 1150 | } |
||
| 1151 | |||
| 1152 | /** |
||
| 1153 | * Set diplomas. |
||
| 1154 | * |
||
| 1155 | * @param string $diplomas |
||
| 1156 | * |
||
| 1157 | * @return User |
||
| 1158 | */ |
||
| 1159 | public function setDiplomas($diplomas) |
||
| 1160 | { |
||
| 1161 | $this->diplomas = $diplomas; |
||
| 1162 | |||
| 1163 | return $this; |
||
| 1164 | } |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * Get diplomas. |
||
| 1168 | * |
||
| 1169 | * @return string |
||
| 1170 | */ |
||
| 1171 | public function getDiplomas() |
||
| 1172 | { |
||
| 1173 | return $this->diplomas; |
||
| 1174 | } |
||
| 1175 | |||
| 1176 | /** |
||
| 1177 | * Set openarea. |
||
| 1178 | * |
||
| 1179 | * @param string $openarea |
||
| 1180 | * |
||
| 1181 | * @return User |
||
| 1182 | */ |
||
| 1183 | public function setOpenarea($openarea) |
||
| 1184 | { |
||
| 1185 | $this->openarea = $openarea; |
||
| 1186 | |||
| 1187 | return $this; |
||
| 1188 | } |
||
| 1189 | |||
| 1190 | /** |
||
| 1191 | * Get openarea. |
||
| 1192 | * |
||
| 1193 | * @return string |
||
| 1194 | */ |
||
| 1195 | public function getOpenarea() |
||
| 1196 | { |
||
| 1197 | return $this->openarea; |
||
| 1198 | } |
||
| 1199 | |||
| 1200 | /** |
||
| 1201 | * Set teach. |
||
| 1202 | * |
||
| 1203 | * @param string $teach |
||
| 1204 | * |
||
| 1205 | * @return User |
||
| 1206 | */ |
||
| 1207 | public function setTeach($teach) |
||
| 1208 | { |
||
| 1209 | $this->teach = $teach; |
||
| 1210 | |||
| 1211 | return $this; |
||
| 1212 | } |
||
| 1213 | |||
| 1214 | /** |
||
| 1215 | * Get teach. |
||
| 1216 | * |
||
| 1217 | * @return string |
||
| 1218 | */ |
||
| 1219 | public function getTeach() |
||
| 1220 | { |
||
| 1221 | return $this->teach; |
||
| 1222 | } |
||
| 1223 | |||
| 1224 | /** |
||
| 1225 | * Set productions. |
||
| 1226 | * |
||
| 1227 | * @param string $productions |
||
| 1228 | * |
||
| 1229 | * @return User |
||
| 1230 | */ |
||
| 1231 | public function setProductions($productions) |
||
| 1232 | { |
||
| 1233 | $this->productions = $productions; |
||
| 1234 | |||
| 1235 | return $this; |
||
| 1236 | } |
||
| 1237 | |||
| 1238 | /** |
||
| 1239 | * Get productions. |
||
| 1240 | * |
||
| 1241 | * @return string |
||
| 1242 | */ |
||
| 1243 | public function getProductions() |
||
| 1244 | { |
||
| 1245 | return $this->productions; |
||
| 1246 | } |
||
| 1247 | |||
| 1248 | /** |
||
| 1249 | * Set language. |
||
| 1250 | * |
||
| 1251 | * @param string $language |
||
| 1252 | * |
||
| 1253 | * @return User |
||
| 1254 | */ |
||
| 1255 | public function setLanguage($language) |
||
| 1256 | { |
||
| 1257 | $this->language = $language; |
||
| 1258 | |||
| 1259 | return $this; |
||
| 1260 | } |
||
| 1261 | |||
| 1262 | /** |
||
| 1263 | * Get language. |
||
| 1264 | * |
||
| 1265 | * @return string |
||
| 1266 | */ |
||
| 1267 | public function getLanguage() |
||
| 1268 | { |
||
| 1269 | return $this->language; |
||
| 1270 | } |
||
| 1271 | |||
| 1272 | /** |
||
| 1273 | * Set registrationDate. |
||
| 1274 | * |
||
| 1275 | * @param \DateTime $registrationDate |
||
| 1276 | * |
||
| 1277 | * @return User |
||
| 1278 | */ |
||
| 1279 | public function setRegistrationDate($registrationDate) |
||
| 1280 | { |
||
| 1281 | $this->registrationDate = $registrationDate; |
||
| 1282 | |||
| 1283 | return $this; |
||
| 1284 | } |
||
| 1285 | |||
| 1286 | /** |
||
| 1287 | * Get registrationDate. |
||
| 1288 | * |
||
| 1289 | * @return \DateTime |
||
| 1290 | */ |
||
| 1291 | public function getRegistrationDate() |
||
| 1292 | { |
||
| 1293 | return $this->registrationDate; |
||
| 1294 | } |
||
| 1295 | |||
| 1296 | /** |
||
| 1297 | * Set expirationDate. |
||
| 1298 | * |
||
| 1299 | * @param \DateTime $expirationDate |
||
| 1300 | * |
||
| 1301 | * @return User |
||
| 1302 | */ |
||
| 1303 | public function setExpirationDate($expirationDate) |
||
| 1304 | { |
||
| 1305 | $this->expirationDate = $expirationDate; |
||
| 1306 | |||
| 1307 | return $this; |
||
| 1308 | } |
||
| 1309 | |||
| 1310 | /** |
||
| 1311 | * Get expirationDate. |
||
| 1312 | * |
||
| 1313 | * @return \DateTime |
||
| 1314 | */ |
||
| 1315 | public function getExpirationDate() |
||
| 1316 | { |
||
| 1317 | return $this->expirationDate; |
||
| 1318 | } |
||
| 1319 | |||
| 1320 | /** |
||
| 1321 | * Set active. |
||
| 1322 | * |
||
| 1323 | * @param bool $active |
||
| 1324 | * |
||
| 1325 | * @return User |
||
| 1326 | */ |
||
| 1327 | public function setActive($active) |
||
| 1328 | { |
||
| 1329 | $this->active = $active; |
||
| 1330 | |||
| 1331 | return $this; |
||
| 1332 | } |
||
| 1333 | |||
| 1334 | /** |
||
| 1335 | * Get active. |
||
| 1336 | * |
||
| 1337 | * @return bool |
||
| 1338 | */ |
||
| 1339 | public function getActive() |
||
| 1340 | { |
||
| 1341 | return $this->active; |
||
| 1342 | } |
||
| 1343 | |||
| 1344 | /** |
||
| 1345 | * Set openid. |
||
| 1346 | * |
||
| 1347 | * @param string $openid |
||
| 1348 | * |
||
| 1349 | * @return User |
||
| 1350 | */ |
||
| 1351 | public function setOpenid($openid) |
||
| 1352 | { |
||
| 1353 | $this->openid = $openid; |
||
| 1354 | |||
| 1355 | return $this; |
||
| 1356 | } |
||
| 1357 | |||
| 1358 | /** |
||
| 1359 | * Get openid. |
||
| 1360 | * |
||
| 1361 | * @return string |
||
| 1362 | */ |
||
| 1363 | public function getOpenid() |
||
| 1364 | { |
||
| 1365 | return $this->openid; |
||
| 1366 | } |
||
| 1367 | |||
| 1368 | /** |
||
| 1369 | * Set theme. |
||
| 1370 | * |
||
| 1371 | * @param string $theme |
||
| 1372 | * |
||
| 1373 | * @return User |
||
| 1374 | */ |
||
| 1375 | public function setTheme($theme) |
||
| 1376 | { |
||
| 1377 | $this->theme = $theme; |
||
| 1378 | |||
| 1379 | return $this; |
||
| 1380 | } |
||
| 1381 | |||
| 1382 | /** |
||
| 1383 | * Get theme. |
||
| 1384 | * |
||
| 1385 | * @return string |
||
| 1386 | */ |
||
| 1387 | public function getTheme() |
||
| 1388 | { |
||
| 1389 | return $this->theme; |
||
| 1390 | } |
||
| 1391 | |||
| 1392 | /** |
||
| 1393 | * Set hrDeptId. |
||
| 1394 | * |
||
| 1395 | * @param int $hrDeptId |
||
| 1396 | * |
||
| 1397 | * @return User |
||
| 1398 | */ |
||
| 1399 | public function setHrDeptId($hrDeptId) |
||
| 1400 | { |
||
| 1401 | $this->hrDeptId = $hrDeptId; |
||
| 1402 | |||
| 1403 | return $this; |
||
| 1404 | } |
||
| 1405 | |||
| 1406 | /** |
||
| 1407 | * Get hrDeptId. |
||
| 1408 | * |
||
| 1409 | * @return int |
||
| 1410 | */ |
||
| 1411 | public function getHrDeptId() |
||
| 1412 | { |
||
| 1413 | return $this->hrDeptId; |
||
| 1414 | } |
||
| 1415 | |||
| 1416 | /** |
||
| 1417 | * @return \DateTime |
||
| 1418 | */ |
||
| 1419 | public function getMemberSince() |
||
| 1420 | { |
||
| 1421 | return $this->registrationDate; |
||
| 1422 | } |
||
| 1423 | |||
| 1424 | /** |
||
| 1425 | * @return bool |
||
| 1426 | */ |
||
| 1427 | public function isOnline() |
||
| 1428 | { |
||
| 1429 | return false; |
||
| 1430 | } |
||
| 1431 | |||
| 1432 | /** |
||
| 1433 | * @return int |
||
| 1434 | */ |
||
| 1435 | public function getIdentifier() |
||
| 1436 | { |
||
| 1437 | return $this->getId(); |
||
| 1438 | } |
||
| 1439 | |||
| 1440 | /** |
||
| 1441 | * @return string |
||
| 1442 | */ |
||
| 1443 | public function getSlug() |
||
| 1444 | { |
||
| 1445 | return $this->getUsername(); |
||
| 1446 | } |
||
| 1447 | |||
| 1448 | /** |
||
| 1449 | * @param string $slug |
||
| 1450 | * |
||
| 1451 | * @return User |
||
| 1452 | */ |
||
| 1453 | public function setSlug($slug) |
||
| 1454 | { |
||
| 1455 | return $this->setUsername($slug); |
||
| 1456 | } |
||
| 1457 | |||
| 1458 | public function setUsername($username) |
||
| 1459 | { |
||
| 1460 | $this->username = $username; |
||
| 1461 | |||
| 1462 | return $this; |
||
| 1463 | } |
||
| 1464 | |||
| 1465 | public function setUsernameCanonical($usernameCanonical) |
||
| 1466 | { |
||
| 1467 | $this->usernameCanonical = $usernameCanonical; |
||
| 1468 | |||
| 1469 | return $this; |
||
| 1470 | } |
||
| 1471 | |||
| 1472 | public function setEmailCanonical($emailCanonical) |
||
| 1473 | { |
||
| 1474 | $this->emailCanonical = $emailCanonical; |
||
| 1475 | |||
| 1476 | return $this; |
||
| 1477 | } |
||
| 1478 | |||
| 1479 | /** |
||
| 1480 | * Set lastLogin. |
||
| 1481 | * |
||
| 1482 | * @param \DateTime $lastLogin |
||
| 1483 | * |
||
| 1484 | * @return User |
||
| 1485 | */ |
||
| 1486 | public function setLastLogin(\DateTime $lastLogin = null) |
||
| 1487 | { |
||
| 1488 | $this->lastLogin = $lastLogin; |
||
| 1489 | |||
| 1490 | return $this; |
||
| 1491 | } |
||
| 1492 | |||
| 1493 | /** |
||
| 1494 | * Get lastLogin. |
||
| 1495 | * |
||
| 1496 | * @return \DateTime |
||
| 1497 | */ |
||
| 1498 | public function getLastLogin() |
||
| 1499 | { |
||
| 1500 | return $this->lastLogin; |
||
| 1501 | } |
||
| 1502 | |||
| 1503 | /** |
||
| 1504 | * Get sessionCourseSubscription. |
||
| 1505 | * |
||
| 1506 | * @return ArrayCollection |
||
| 1507 | */ |
||
| 1508 | public function getSessionCourseSubscriptions() |
||
| 1509 | { |
||
| 1510 | return $this->sessionCourseSubscriptions; |
||
| 1511 | } |
||
| 1512 | |||
| 1513 | /** |
||
| 1514 | * @param $value |
||
| 1515 | * @param string[][] $value |
||
| 1516 | * |
||
| 1517 | * @return $this |
||
| 1518 | */ |
||
| 1519 | public function setSessionCourseSubscriptions(array $value) |
||
| 1520 | { |
||
| 1521 | $this->sessionCourseSubscriptions = $value; |
||
| 1522 | |||
| 1523 | return $this; |
||
| 1524 | } |
||
| 1525 | |||
| 1526 | /** |
||
| 1527 | * @return string |
||
| 1528 | */ |
||
| 1529 | public function getConfirmationToken() |
||
| 1530 | { |
||
| 1531 | return $this->confirmationToken; |
||
| 1532 | } |
||
| 1533 | |||
| 1534 | /** |
||
| 1535 | * @param string $confirmationToken |
||
| 1536 | * |
||
| 1537 | * @return User |
||
| 1538 | */ |
||
| 1539 | public function setConfirmationToken($confirmationToken) |
||
| 1540 | { |
||
| 1541 | $this->confirmationToken = $confirmationToken; |
||
| 1542 | |||
| 1543 | return $this; |
||
| 1544 | } |
||
| 1545 | |||
| 1546 | /** |
||
| 1547 | * @return \DateTime |
||
| 1548 | */ |
||
| 1549 | public function getPasswordRequestedAt() |
||
| 1550 | { |
||
| 1551 | return $this->passwordRequestedAt; |
||
| 1552 | } |
||
| 1553 | |||
| 1554 | /*public function isPasswordRequestNonExpired($ttl) |
||
| 1555 | { |
||
| 1556 | return $this->getPasswordRequestedAt() instanceof \DateTime && |
||
| 1557 | $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time(); |
||
| 1558 | }*/ |
||
| 1559 | |||
| 1560 | public function getUsername(): string |
||
| 1561 | { |
||
| 1562 | return (string) $this->username; |
||
| 1563 | } |
||
| 1564 | |||
| 1565 | public function getPlainPassword(): ?string |
||
| 1568 | } |
||
| 1569 | |||
| 1570 | public function setPlainPassword(string $password) |
||
| 1571 | { |
||
| 1572 | $this->plainPassword = $password; |
||
| 1573 | |||
| 1574 | // forces the object to look "dirty" to Doctrine. Avoids |
||
| 1575 | // Doctrine *not* saving this entity, if only plainPassword changes |
||
| 1576 | $this->password = null; |
||
| 1577 | |||
| 1578 | return $this; |
||
| 1579 | } |
||
| 1580 | |||
| 1581 | /** |
||
| 1582 | * Returns the expiration date. |
||
| 1583 | * |
||
| 1584 | * @return \DateTime|null |
||
| 1585 | */ |
||
| 1586 | public function getExpiresAt() |
||
| 1587 | { |
||
| 1588 | return $this->expiresAt; |
||
| 1589 | } |
||
| 1590 | |||
| 1591 | /** |
||
| 1592 | * Returns the credentials expiration date. |
||
| 1593 | * |
||
| 1594 | * @return \DateTime |
||
| 1595 | */ |
||
| 1596 | public function getCredentialsExpireAt() |
||
| 1597 | { |
||
| 1598 | return $this->credentialsExpireAt; |
||
| 1599 | } |
||
| 1600 | |||
| 1601 | /** |
||
| 1602 | * Sets the credentials expiration date. |
||
| 1603 | * |
||
| 1604 | * @return User |
||
| 1605 | */ |
||
| 1606 | public function setCredentialsExpireAt(\DateTime $date = null) |
||
| 1607 | { |
||
| 1608 | $this->credentialsExpireAt = $date; |
||
| 1609 | |||
| 1610 | return $this; |
||
| 1611 | } |
||
| 1612 | |||
| 1613 | public function addGroup($group) |
||
| 1614 | { |
||
| 1615 | if (!$this->getGroups()->contains($group)) { |
||
| 1616 | $this->getGroups()->add($group); |
||
| 1617 | } |
||
| 1618 | |||
| 1619 | return $this; |
||
| 1620 | } |
||
| 1621 | |||
| 1622 | /** |
||
| 1623 | * Sets the user groups. |
||
| 1624 | * |
||
| 1625 | * @param array $groups |
||
| 1626 | * |
||
| 1627 | * @return User |
||
| 1628 | */ |
||
| 1629 | public function setGroups($groups) |
||
| 1630 | { |
||
| 1631 | foreach ($groups as $group) { |
||
| 1632 | $this->addGroup($group); |
||
| 1633 | } |
||
| 1634 | |||
| 1635 | return $this; |
||
| 1636 | } |
||
| 1637 | |||
| 1638 | /** |
||
| 1639 | * @return string |
||
| 1640 | */ |
||
| 1641 | public function getFullname() |
||
| 1642 | { |
||
| 1643 | return sprintf('%s %s', $this->getFirstname(), $this->getLastname()); |
||
| 1644 | } |
||
| 1645 | |||
| 1646 | public function getGroups() |
||
| 1647 | { |
||
| 1648 | return $this->groups; |
||
| 1649 | } |
||
| 1650 | |||
| 1651 | /** |
||
| 1652 | * @return array |
||
| 1653 | */ |
||
| 1654 | public function getGroupNames() |
||
| 1655 | { |
||
| 1656 | $names = []; |
||
| 1657 | foreach ($this->getGroups() as $group) { |
||
| 1658 | $names[] = $group->getName(); |
||
| 1659 | } |
||
| 1660 | |||
| 1661 | return $names; |
||
| 1662 | } |
||
| 1663 | |||
| 1664 | /** |
||
| 1665 | * @param string $name |
||
| 1666 | * |
||
| 1667 | * @return bool |
||
| 1668 | */ |
||
| 1669 | public function hasGroup($name) |
||
| 1670 | { |
||
| 1671 | return in_array($name, $this->getGroupNames()); |
||
| 1672 | } |
||
| 1673 | |||
| 1674 | public function removeGroup($group) |
||
| 1675 | { |
||
| 1676 | if ($this->getGroups()->contains($group)) { |
||
| 1677 | $this->getGroups()->removeElement($group); |
||
| 1678 | } |
||
| 1679 | |||
| 1680 | return $this; |
||
| 1681 | } |
||
| 1682 | |||
| 1683 | /** |
||
| 1684 | * @param string $role |
||
| 1685 | * |
||
| 1686 | * @return $this |
||
| 1687 | */ |
||
| 1688 | public function addRole($role) |
||
| 1689 | { |
||
| 1690 | $role = strtoupper($role); |
||
| 1691 | if ($role === static::ROLE_DEFAULT) { |
||
| 1692 | return $this; |
||
| 1693 | } |
||
| 1694 | |||
| 1695 | if (!in_array($role, $this->roles, true)) { |
||
| 1696 | $this->roles[] = $role; |
||
| 1697 | } |
||
| 1698 | |||
| 1699 | return $this; |
||
| 1700 | } |
||
| 1701 | |||
| 1702 | /** |
||
| 1703 | * Returns the user roles. |
||
| 1704 | * |
||
| 1705 | * @return array The roles |
||
| 1706 | */ |
||
| 1707 | public function getRoles() |
||
| 1708 | { |
||
| 1709 | $roles = $this->roles; |
||
| 1710 | |||
| 1711 | foreach ($this->getGroups() as $group) { |
||
| 1712 | $roles = array_merge($roles, $group->getRoles()); |
||
| 1713 | } |
||
| 1714 | |||
| 1715 | // we need to make sure to have at least one role |
||
| 1716 | $roles[] = 'ROLE_USER'; |
||
| 1717 | |||
| 1718 | return array_unique($roles); |
||
| 1719 | } |
||
| 1720 | |||
| 1721 | public function isAccountNonExpired() |
||
| 1722 | { |
||
| 1723 | /*if (true === $this->expired) { |
||
| 1724 | return false; |
||
| 1725 | } |
||
| 1726 | |||
| 1727 | if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) { |
||
| 1728 | return false; |
||
| 1729 | }*/ |
||
| 1730 | |||
| 1731 | return true; |
||
| 1732 | } |
||
| 1733 | |||
| 1734 | public function isAccountNonLocked() |
||
| 1735 | { |
||
| 1736 | return true; |
||
| 1737 | //return !$this->locked; |
||
| 1738 | } |
||
| 1739 | |||
| 1740 | public function isCredentialsNonExpired() |
||
| 1741 | { |
||
| 1742 | /*if (true === $this->credentialsExpired) { |
||
| 1743 | return false; |
||
| 1744 | } |
||
| 1745 | |||
| 1746 | if (null !== $this->credentialsExpireAt && $this->credentialsExpireAt->getTimestamp() < time()) { |
||
| 1747 | return false; |
||
| 1748 | }*/ |
||
| 1749 | |||
| 1750 | return true; |
||
| 1751 | } |
||
| 1752 | |||
| 1753 | /** |
||
| 1754 | * @return bool |
||
| 1755 | */ |
||
| 1756 | public function getCredentialsExpired() |
||
| 1757 | { |
||
| 1758 | return $this->credentialsExpired; |
||
| 1759 | } |
||
| 1760 | |||
| 1761 | /** |
||
| 1762 | * @param bool $boolean |
||
| 1763 | * |
||
| 1764 | * @return User |
||
| 1765 | */ |
||
| 1766 | public function setCredentialsExpired($boolean) |
||
| 1767 | { |
||
| 1768 | $this->credentialsExpired = $boolean; |
||
| 1769 | |||
| 1770 | return $this; |
||
| 1771 | } |
||
| 1772 | |||
| 1773 | /** |
||
| 1774 | * @param $boolean |
||
| 1775 | * |
||
| 1776 | * @return $this |
||
| 1777 | */ |
||
| 1778 | public function setEnabled($boolean) |
||
| 1779 | { |
||
| 1780 | $this->enabled = (bool) $boolean; |
||
| 1781 | |||
| 1782 | return $this; |
||
| 1783 | } |
||
| 1784 | |||
| 1785 | /** |
||
| 1786 | * @return bool |
||
| 1787 | */ |
||
| 1788 | public function getExpired() |
||
| 1789 | { |
||
| 1790 | return $this->expired; |
||
| 1791 | } |
||
| 1792 | |||
| 1793 | /** |
||
| 1794 | * Sets this user to expired. |
||
| 1795 | * |
||
| 1796 | * @param bool $boolean |
||
| 1797 | * |
||
| 1798 | * @return User |
||
| 1799 | */ |
||
| 1800 | public function setExpired($boolean) |
||
| 1801 | { |
||
| 1802 | $this->expired = (bool) $boolean; |
||
| 1803 | |||
| 1804 | return $this; |
||
| 1805 | } |
||
| 1806 | |||
| 1807 | /** |
||
| 1808 | * @return User |
||
| 1809 | */ |
||
| 1810 | public function setExpiresAt(\DateTime $date) |
||
| 1811 | { |
||
| 1812 | $this->expiresAt = $date; |
||
| 1813 | |||
| 1814 | return $this; |
||
| 1815 | } |
||
| 1816 | |||
| 1817 | public function getLocked(): bool |
||
| 1818 | { |
||
| 1819 | return $this->locked; |
||
| 1820 | } |
||
| 1821 | |||
| 1822 | /** |
||
| 1823 | * @param $boolean |
||
| 1824 | * |
||
| 1825 | * @return $this |
||
| 1826 | */ |
||
| 1827 | public function setLocked($boolean) |
||
| 1828 | { |
||
| 1829 | $this->locked = $boolean; |
||
| 1830 | |||
| 1831 | return $this; |
||
| 1832 | } |
||
| 1833 | |||
| 1834 | /** |
||
| 1835 | * @return $this |
||
| 1836 | */ |
||
| 1837 | public function setRoles(array $roles) |
||
| 1838 | { |
||
| 1839 | $this->roles = []; |
||
| 1840 | |||
| 1841 | foreach ($roles as $role) { |
||
| 1842 | $this->addRole($role); |
||
| 1843 | } |
||
| 1844 | |||
| 1845 | return $this; |
||
| 1846 | } |
||
| 1847 | |||
| 1848 | /** |
||
| 1849 | * Get achievedSkills. |
||
| 1850 | * |
||
| 1851 | * @return ArrayCollection |
||
| 1852 | */ |
||
| 1853 | public function getAchievedSkills() |
||
| 1854 | { |
||
| 1855 | return $this->achievedSkills; |
||
| 1856 | } |
||
| 1857 | |||
| 1858 | /** |
||
| 1859 | * @param $value |
||
| 1860 | * @param string[] $value |
||
| 1861 | * |
||
| 1862 | * @return $this |
||
| 1863 | */ |
||
| 1864 | public function setAchievedSkills(array $value) |
||
| 1865 | { |
||
| 1866 | $this->achievedSkills = $value; |
||
| 1867 | |||
| 1868 | return $this; |
||
| 1869 | } |
||
| 1870 | |||
| 1871 | /** |
||
| 1872 | * Check if the user has the skill. |
||
| 1873 | * |
||
| 1874 | * @param Skill $skill The skill |
||
| 1875 | * |
||
| 1876 | * @return bool |
||
| 1877 | */ |
||
| 1878 | public function hasSkill(Skill $skill) |
||
| 1879 | { |
||
| 1880 | $achievedSkills = $this->getAchievedSkills(); |
||
| 1881 | |||
| 1882 | foreach ($achievedSkills as $userSkill) { |
||
| 1883 | if ($userSkill->getSkill()->getId() !== $skill->getId()) { |
||
| 1884 | continue; |
||
| 1885 | } |
||
| 1886 | |||
| 1887 | return true; |
||
| 1888 | } |
||
| 1889 | } |
||
| 1890 | |||
| 1891 | /** |
||
| 1892 | * @return bool |
||
| 1893 | */ |
||
| 1894 | public function isProfileCompleted() |
||
| 1895 | { |
||
| 1896 | return $this->profileCompleted; |
||
| 1897 | } |
||
| 1898 | |||
| 1899 | /** |
||
| 1900 | * @return User |
||
| 1901 | */ |
||
| 1902 | public function setProfileCompleted($profileCompleted) |
||
| 1903 | { |
||
| 1904 | $this->profileCompleted = $profileCompleted; |
||
| 1905 | |||
| 1906 | return $this; |
||
| 1907 | } |
||
| 1908 | |||
| 1909 | /** |
||
| 1910 | * Sets the AccessUrl for the current user in memory. |
||
| 1911 | * |
||
| 1912 | * @return $this |
||
| 1913 | */ |
||
| 1914 | public function setCurrentUrl(AccessUrl $url) |
||
| 1915 | { |
||
| 1916 | $urlList = $this->getPortals(); |
||
| 1917 | /** @var AccessUrlRelUser $item */ |
||
| 1918 | foreach ($urlList as $item) { |
||
| 1919 | if ($item->getUrl()->getId() === $url->getId()) { |
||
| 1920 | $this->currentUrl = $url; |
||
| 1921 | |||
| 1922 | break; |
||
| 1923 | } |
||
| 1924 | } |
||
| 1925 | |||
| 1926 | return $this; |
||
| 1927 | } |
||
| 1928 | |||
| 1929 | /** |
||
| 1930 | * @return AccessUrl |
||
| 1931 | */ |
||
| 1932 | public function getCurrentUrl() |
||
| 1933 | { |
||
| 1934 | return $this->currentUrl; |
||
| 1935 | } |
||
| 1936 | |||
| 1937 | /** |
||
| 1938 | * Get sessionAsGeneralCoach. |
||
| 1939 | * |
||
| 1940 | * @return ArrayCollection |
||
| 1941 | */ |
||
| 1942 | public function getSessionAsGeneralCoach() |
||
| 1943 | { |
||
| 1944 | return $this->sessionAsGeneralCoach; |
||
| 1945 | } |
||
| 1946 | |||
| 1947 | /** |
||
| 1948 | * Get sessionAsGeneralCoach. |
||
| 1949 | * |
||
| 1950 | * @param ArrayCollection $value |
||
| 1951 | * |
||
| 1952 | * @return $this |
||
| 1953 | */ |
||
| 1954 | public function setSessionAsGeneralCoach($value) |
||
| 1955 | { |
||
| 1956 | $this->sessionAsGeneralCoach = $value; |
||
| 1957 | |||
| 1958 | return $this; |
||
| 1959 | } |
||
| 1960 | |||
| 1961 | public function getCommentedUserSkills() |
||
| 1962 | { |
||
| 1963 | return $this->commentedUserSkills; |
||
| 1964 | } |
||
| 1965 | |||
| 1966 | /** |
||
| 1967 | * @return User |
||
| 1968 | */ |
||
| 1969 | public function setCommentedUserSkills(array $commentedUserSkills) |
||
| 1970 | { |
||
| 1971 | $this->commentedUserSkills = $commentedUserSkills; |
||
| 1972 | |||
| 1973 | return $this; |
||
| 1974 | } |
||
| 1975 | |||
| 1976 | /** |
||
| 1977 | * @return bool |
||
| 1978 | */ |
||
| 1979 | public function isEqualTo(UserInterface $user) |
||
| 1980 | { |
||
| 1981 | if ($this->password !== $user->getPassword()) { |
||
| 1982 | return false; |
||
| 1983 | } |
||
| 1984 | |||
| 1985 | if ($this->salt !== $user->getSalt()) { |
||
| 1986 | return false; |
||
| 1987 | } |
||
| 1988 | |||
| 1989 | if ($this->username !== $user->getUsername()) { |
||
| 1990 | return false; |
||
| 1991 | } |
||
| 1992 | |||
| 1993 | return true; |
||
| 1994 | } |
||
| 1995 | |||
| 1996 | /** |
||
| 1997 | * Get sentMessages. |
||
| 1998 | * |
||
| 1999 | * @return ArrayCollection |
||
| 2000 | */ |
||
| 2001 | public function getSentMessages() |
||
| 2002 | { |
||
| 2003 | return $this->sentMessages; |
||
| 2004 | } |
||
| 2005 | |||
| 2006 | /** |
||
| 2007 | * Get receivedMessages. |
||
| 2008 | * |
||
| 2009 | * @return ArrayCollection |
||
| 2010 | */ |
||
| 2011 | public function getReceivedMessages() |
||
| 2012 | { |
||
| 2013 | return $this->receivedMessages; |
||
| 2014 | } |
||
| 2015 | |||
| 2016 | /** |
||
| 2017 | * @param int $lastId Optional. The ID of the last received message |
||
| 2018 | */ |
||
| 2019 | public function getUnreadReceivedMessages($lastId = 0): ArrayCollection |
||
| 2020 | { |
||
| 2021 | $criteria = Criteria::create(); |
||
| 2022 | $criteria->where( |
||
| 2023 | Criteria::expr()->eq('msgStatus', MESSAGE_STATUS_UNREAD) |
||
| 2024 | ); |
||
| 2025 | |||
| 2026 | if ($lastId > 0) { |
||
| 2027 | $criteria->andWhere( |
||
| 2028 | Criteria::expr()->gt('id', (int) $lastId) |
||
| 2029 | ); |
||
| 2030 | } |
||
| 2031 | |||
| 2032 | $criteria->orderBy(['sendDate' => Criteria::DESC]); |
||
| 2033 | |||
| 2034 | return $this->receivedMessages->matching($criteria); |
||
| 2035 | } |
||
| 2036 | |||
| 2037 | public function getCourseGroupsAsMember(): Collection |
||
| 2038 | { |
||
| 2039 | return $this->courseGroupsAsMember; |
||
| 2040 | } |
||
| 2041 | |||
| 2042 | public function getCourseGroupsAsTutor(): Collection |
||
| 2043 | { |
||
| 2044 | return $this->courseGroupsAsTutor; |
||
| 2045 | } |
||
| 2046 | |||
| 2047 | public function getCourseGroupsAsMemberFromCourse(Course $course): ArrayCollection |
||
| 2048 | { |
||
| 2049 | $criteria = Criteria::create(); |
||
| 2050 | $criteria->where( |
||
| 2051 | Criteria::expr()->eq('cId', $course) |
||
| 2052 | ); |
||
| 2053 | |||
| 2054 | return $this->courseGroupsAsMember->matching($criteria); |
||
| 2055 | } |
||
| 2056 | |||
| 2057 | public function getFirstname() |
||
| 2058 | { |
||
| 2059 | return $this->firstname; |
||
| 2060 | } |
||
| 2061 | |||
| 2062 | public function getLastname() |
||
| 2063 | { |
||
| 2064 | return $this->lastname; |
||
| 2065 | } |
||
| 2066 | |||
| 2067 | public function eraseCredentials() |
||
| 2068 | { |
||
| 2069 | $this->plainPassword = null; |
||
| 2070 | } |
||
| 2071 | |||
| 2072 | public function hasRole($role) |
||
| 2073 | { |
||
| 2074 | return in_array(strtoupper($role), $this->getRoles(), true); |
||
| 2075 | } |
||
| 2076 | |||
| 2077 | public function isSuperAdmin() |
||
| 2078 | { |
||
| 2079 | return $this->hasRole('ROLE_SUPER_ADMIN'); |
||
| 2080 | } |
||
| 2081 | |||
| 2082 | public function isUser(UserInterface $user = null) |
||
| 2083 | { |
||
| 2084 | return null !== $user && $this->getId() === $user->getId(); |
||
| 2085 | } |
||
| 2086 | |||
| 2087 | public function removeRole($role) |
||
| 2088 | { |
||
| 2089 | if (false !== $key = array_search(strtoupper($role), $this->roles, true)) { |
||
| 2090 | unset($this->roles[$key]); |
||
| 2091 | $this->roles = array_values($this->roles); |
||
| 2092 | } |
||
| 2093 | |||
| 2094 | return $this; |
||
| 2095 | } |
||
| 2096 | |||
| 2097 | public function getUsernameCanonical() |
||
| 2100 | } |
||
| 2101 | |||
| 2102 | public function getEmailCanonical() |
||
| 2103 | { |
||
| 2104 | return $this->emailCanonical; |
||
| 2105 | } |
||
| 2106 | |||
| 2107 | /** |
||
| 2108 | * @param string $timezone |
||
| 2109 | * |
||
| 2110 | * @return User |
||
| 2111 | */ |
||
| 2112 | public function setTimezone($timezone) |
||
| 2113 | { |
||
| 2114 | $this->timezone = $timezone; |
||
| 2115 | |||
| 2116 | return $this; |
||
| 2117 | } |
||
| 2118 | |||
| 2119 | /** |
||
| 2120 | * @return string |
||
| 2121 | */ |
||
| 2122 | public function getTimezone() |
||
| 2123 | { |
||
| 2124 | return $this->timezone; |
||
| 2125 | } |
||
| 2126 | |||
| 2127 | /** |
||
| 2128 | * @param string $locale |
||
| 2129 | * |
||
| 2130 | * @return User |
||
| 2131 | */ |
||
| 2132 | public function setLocale($locale) |
||
| 2137 | } |
||
| 2138 | |||
| 2139 | /** |
||
| 2140 | * @return string |
||
| 2141 | */ |
||
| 2142 | public function getLocale() |
||
| 2143 | { |
||
| 2144 | return $this->locale; |
||
| 2145 | } |
||
| 2146 | |||
| 2147 | /** |
||
| 2148 | * @return string |
||
| 2149 | */ |
||
| 2150 | public function getApiToken() |
||
| 2151 | { |
||
| 2152 | return $this->apiToken; |
||
| 2153 | } |
||
| 2154 | |||
| 2155 | /** |
||
| 2156 | * @param string $apiToken |
||
| 2157 | * |
||
| 2158 | * @return User |
||
| 2159 | */ |
||
| 2160 | public function setApiToken($apiToken) |
||
| 2161 | { |
||
| 2162 | $this->apiToken = $apiToken; |
||
| 2163 | |||
| 2164 | return $this; |
||
| 2165 | } |
||
| 2166 | |||
| 2167 | public function getWebsite(): ?string |
||
| 2168 | { |
||
| 2169 | return $this->website; |
||
| 2170 | } |
||
| 2171 | |||
| 2172 | public function setWebsite(string $website): self |
||
| 2173 | { |
||
| 2174 | $this->website = $website; |
||
| 2175 | |||
| 2176 | return $this; |
||
| 2177 | } |
||
| 2178 | |||
| 2179 | public function getBiography(): ?string |
||
| 2182 | } |
||
| 2183 | |||
| 2184 | public function setBiography(string $biography): self |
||
| 2185 | { |
||
| 2186 | $this->biography = $biography; |
||
| 2187 | |||
| 2188 | return $this; |
||
| 2189 | } |
||
| 2190 | |||
| 2191 | /** |
||
| 2192 | * @param \DateTime $dateOfBirth |
||
| 2193 | * |
||
| 2194 | * @return User |
||
| 2195 | */ |
||
| 2196 | public function setDateOfBirth($dateOfBirth) |
||
| 2197 | { |
||
| 2198 | $this->dateOfBirth = $dateOfBirth; |
||
| 2199 | |||
| 2200 | return $this; |
||
| 2201 | } |
||
| 2202 | |||
| 2203 | /** |
||
| 2204 | * @return \DateTime |
||
| 2205 | */ |
||
| 2206 | public function getDateOfBirth() |
||
| 2207 | { |
||
| 2208 | return $this->dateOfBirth; |
||
| 2209 | } |
||
| 2210 | |||
| 2211 | public function getCourseGroupsAsTutorFromCourse(Course $course): ArrayCollection |
||
| 2219 | } |
||
| 2220 | |||
| 2221 | /** |
||
| 2222 | * Retreives this user's related sessions. |
||
| 2223 | * |
||
| 2224 | * @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key |
||
| 2225 | * |
||
| 2226 | * @return Session[] |
||
| 2227 | */ |
||
| 2228 | public function getSessions($relationType) |
||
| 2229 | { |
||
| 2230 | $sessions = []; |
||
| 2231 | foreach ($this->sessions as $sessionRelUser) { |
||
| 2232 | if ($sessionRelUser->getRelationType() == $relationType) { |
||
| 2233 | $sessions[] = $sessionRelUser->getSession(); |
||
| 2234 | } |
||
| 2235 | } |
||
| 2236 | |||
| 2237 | return $sessions; |
||
| 2238 | } |
||
| 2239 | |||
| 2240 | /** |
||
| 2241 | * Retreives this user's related student sessions. |
||
| 2242 | * |
||
| 2243 | * @return Session[] |
||
| 2244 | */ |
||
| 2245 | public function getStudentSessions() |
||
| 2246 | { |
||
| 2247 | return $this->getSessions(0); |
||
| 2248 | } |
||
| 2249 | |||
| 2250 | /** |
||
| 2251 | * Retreives this user's related DRH sessions. |
||
| 2252 | * |
||
| 2253 | * @return Session[] |
||
| 2254 | */ |
||
| 2255 | public function getDRHSessions() |
||
| 2256 | { |
||
| 2257 | return $this->getSessions(1); |
||
| 2258 | } |
||
| 2259 | |||
| 2260 | /** |
||
| 2261 | * Get this user's related accessible sessions of a type, student by default. |
||
| 2262 | * |
||
| 2263 | * @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key |
||
| 2264 | * |
||
| 2265 | * @return Session[] |
||
| 2266 | */ |
||
| 2267 | public function getCurrentlyAccessibleSessions($relationType = 0) |
||
| 2268 | { |
||
| 2269 | $sessions = []; |
||
| 2270 | foreach ($this->getSessions($relationType) as $session) { |
||
| 2271 | if ($session->isCurrentlyAccessible()) { |
||
| 2272 | $sessions[] = $session; |
||
| 2273 | } |
||
| 2274 | } |
||
| 2275 | |||
| 2276 | return $sessions; |
||
| 2277 | } |
||
| 2278 | } |
||
| 2279 |
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..