src/Entity/User.php line 24
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use App\Repository\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Exception;use Scheb\TwoFactorBundle\Model\Totp\TotpConfigurationInterface;use Scheb\TwoFactorBundle\Model\Totp\TwoFactorInterface;use Scheb\TwoFactorBundle\Model\Totp\TotpConfiguration;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use Symfony\Component\Validator\Constraints as Assert;use Symfony\Component\Validator\Mapping\ClassMetadata;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;#[ORM\Entity(repositoryClass: UserRepository::class)]#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]#[UniqueEntity(fields: ['uuid'], message: 'There is already an account with this ID')]class User implements UserInterface, PasswordAuthenticatedUserInterface, TwoFactorInterface{public static function loadValidatorMetadata(ClassMetadata $metadata): void{$metadata->addPropertyConstraint('rawPassword', new Assert\NotCompromisedPassword());}private string $rawPassword;/*** @return string*/public function getRawPassword():string{return $this->rawPassword;}public function setRawPassword($rawPassword):self{$this->rawPassword = $rawPassword;return $this;}#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]protected ?int $id = null;#[ORM\OneToOne(inversedBy: "user", targetEntity: UserDetails::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "userdetails", nullable: false)]protected ?UserDetails $userdetails;#[ORM\OneToOne(inversedBy: "user", targetEntity: UserRegister::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "register", nullable: true)]protected ?UserRegister $register;#[ORM\OneToOne(inversedBy: "user", targetEntity: UserDashboard::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "dashboard", nullable: true)]protected ?UserDashboard $dashboard;#[ORM\OneToOne(inversedBy: "user", targetEntity: UserStudio::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "userStudio", nullable: true)]protected ?UserStudio $userStudio;#[ORM\OneToOne(mappedBy: 'user', targetEntity: FranchiseNehmer::class)]protected FranchiseNehmer $franchise;#[ORM\Column(type: "string",length: 255, nullable: true)]private ?string $totpSecret = null;#[ORM\Column(length: 180, unique: true)]private ?string $email = null;#[ORM\Column]private array $roles = [];/*** @var ?string The hashed password*/#[ORM\Column]private ?string $password = null;#[ORM\Column(length: 36,unique: true)]private ?string $uuid;#[ORM\Column(length: 255, nullable: true)]private ?string $locale = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: OAuth2UserConsent::class, orphanRemoval: true)]private Collection $oAuth2UserConsents;/*** @throws Exception*/public function __construct(){$this->oAuth2UserConsents = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getEmail(): ?string{return $this->email;}public function setEmail(string $email): self{$this->email = $email;return $this;}public function getSalt(): ?string{return null;}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{// return $this->email;return $this->uuid;}/*** @see UserInterface*/public function getRoles(): array{$roles = $this->roles;// guarantee every user at least has ROLE_USER$roles[] = 'ROLE_USER';return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}/*** @see UserInterface*/public function eraseCredentials(){// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}/* public function __toString(){$format = "User (id: %d,email: %s, role: %s, information: %s)\n";return sprintf($format, $this->id, $this->email, $this->roles, $this->information);}*/public function getUserdetails(): ?UserDetails{return $this->userdetails;}public function setUserdetails(UserDetails $userdetails): self{$this->userdetails = $userdetails;return $this;}public function getLocale(): ?string{return $this->locale;}public function setLocale(string $locale): self{$this->locale = $locale;return $this;}public function getRegister(): ?UserRegister{return $this->register;}public function setRegister(?UserRegister $register): self{$this->register = $register;return $this;}/*** @return Collection<int, OAuth2UserConsent>*/public function getOAuth2UserConsents(): Collection{return $this->oAuth2UserConsents;}public function addOAuth2UserConsent(OAuth2UserConsent $oAuth2UserConsent): self{if (!$this->oAuth2UserConsents->contains($oAuth2UserConsent)) {$this->oAuth2UserConsents->add($oAuth2UserConsent);$oAuth2UserConsent->setUser($this);}return $this;}public function removeOAuth2UserConsent(OAuth2UserConsent $oAuth2UserConsent): self{if ($this->oAuth2UserConsents->removeElement($oAuth2UserConsent)) {// set the owning side to null (unless already changed)if ($oAuth2UserConsent->getUser() === $this) {$oAuth2UserConsent->setUser(null);}}return $this;}public function getUuid(): ?string{return $this->uuid;}public function setUuid(string $uuid): self{$this->uuid = $uuid;return $this;}public function isTotpAuthenticationEnabled(): bool{return (bool)$this->totpSecret;}public function getTotpAuthenticationUsername(): string{return $this->getUserIdentifier();}public function getTotpAuthenticationConfiguration(): ?TotpConfigurationInterface{return new TotpConfiguration($this->totpSecret, TotpConfiguration::ALGORITHM_SHA1, 30, 6);}public function getTotpSecret(): string{return $this->totpSecret ?? '';}public function setTotpSecret(?string $totpSecret): self{$this->totpSecret = $totpSecret;return $this;}public function getFranchise(): ?FranchiseNehmer{return $this->franchise;}public function setFranchise(?FranchiseNehmer $franchise): self{// unset the owning side of the relation if necessaryif ($franchise === null && $this->franchise !== null) {$this->franchise->setUser(null);}// set the owning side of the relation if necessaryif ($franchise !== null && $franchise->getUser() !== $this) {$franchise->setUser($this);}$this->franchise = $franchise;return $this;}public function getDashboard(): ?UserDashboard{return $this->dashboard;}public function setDashboard(?UserDashboard $dashboard): self{$this->dashboard = $dashboard;return $this;}public function getUserStudio(): ?UserStudio{return $this->userStudio;}public function setUserStudio(?UserStudio $userStudio): self{$this->userStudio = $userStudio;return $this;}}