| 451 | === Using friendsofsymfony/user-bundle === |
| 452 | ==== FOS\UserBundle\Model\UserInterface ==== |
| 453 | * [http://php.net/manual/en/class.serializable.php The Serializable interface] |
| 454 | ===== Symfony\Component\Security\Core\User\UserInterface ===== |
| 455 | * Represents the interface that all user classes must implement. |
| 456 | * Objects that implement this interface are created and loaded by different objects that implement UserProviderInterface |
| 457 | * Users are serialized to be saved in the session. |
| 458 | * http://api.symfony.com/master/Symfony/Component/Security/Core/User/UserInterface.html |
| 459 | * //[https://symfony.com/doc/current/security/custom_provider.html How to Create a custom User Provider]// |
| 460 | * //[http://symfony.com/doc/current/security/entity_provider.html How to Load Security Users from the Database (the Entity Provider)]// |
| 461 | * //[http://symfony2-document.readthedocs.io/en/latest/cookbook/security/entity_provider.html How to load Security Users from the Database (the Entity Provider)]// |
| 462 | |
| 463 | interface UserInterface |
| 464 | * string getUsername() |
| 465 | * (Role|string)[] getRoles() |
| 466 | * string getPassword() This should be the encoded password. |
| 467 | * eraseCredentials() |
| 468 | * string|null getSalt() |
| 469 | ===== Symfony\Component\Security\Core\User\AdvancedUserInterface ===== |
| 470 | * Adds extra features to a user class related to account status flags. |
| 471 | * http://api.symfony.com/master/Symfony/Component/Security/Core/User/AdvancedUserInterface.html |
| 472 | * //[http://symfony.com/doc/current/security/entity_provider.html#security-advanced-user-interface Forbid Inactive Users (AdvancedUserInterface)]// |
| 473 | |
| 474 | interface AdvancedUserInterface implements UserInterface |
| 475 | * bool isAccountNonExpired() |
| 476 | * bool isAccountNonLocked() |
| 477 | * bool isCredentialsNonExpired() |
| 478 | * bool isEnabled() |
| 479 | ===== FOS\UserBundle\Model\UserInterface ===== |
| 480 | {{{#!sh |
| 481 | interface UserInterface extends AdvancedUserInterface, \Serializable |
| 482 | |
| 483 | const ROLE_DEFAULT = 'ROLE_USER'; |
| 484 | const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN'; |
| 485 | |
| 486 | mixed getId() |
| 487 | |
| 488 | # string getUsername() |
| 489 | self setUsername(string $username) |
| 490 | self setUsernameCanonical(string $usernameCanonical) |
| 491 | string getUsernameCanonical() |
| 492 | |
| 493 | # (Role|string)[] getRoles() |
| 494 | self setRoles(array $roles) |
| 495 | self function addRole(string $role) |
| 496 | self removeRole(string $role) |
| 497 | bool hasRole(string $role) # Never use this, instead: $authorizationChecker->isGranted('ROLE_USER') |
| 498 | |
| 499 | self setSuperAdmin(bool $superAdmin) |
| 500 | bool isSuperAdmin() |
| 501 | |
| 502 | # string getPassword() |
| 503 | self setPassword(string $password) # also hashed |
| 504 | # eraseCredentials() |
| 505 | self setPlainPassword(string $password) |
| 506 | string getPlainPassword() # !! 2017-07 |
| 507 | # string|null getSalt() |
| 508 | setSalt(string|null $salt) |
| 509 | self setPasswordRequestedAt(DateTime $date = null) |
| 510 | int isPasswordRequestNonExpired(int $ttl) # seconds |
| 511 | self setConfirmationToken(string $confirmationToken) |
| 512 | string getConfirmationToken() |
| 513 | # bool isCredentialsNonExpired() |
| 514 | |
| 515 | self setEmail(string $email) |
| 516 | string getEmail() |
| 517 | self setEmailCanonical(string $emailCanonical) |
| 518 | string getEmailCanonical() |
| 519 | |
| 520 | # bool isAccountNonExpired() |
| 521 | # bool isAccountNonLocked() |
| 522 | # bool isEnabled() |
| 523 | self setEnabled(bool $enabled) |
| 524 | |
| 525 | self setLastLogin(DateTime $time = null) |
| 526 | }}} |