src/Entity/User.php line 17
<?phpnamespace App\Entity;use App\Repository\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use Symfony\Component\Yaml\Yaml;use Symfony\Component\HttpKernel\KernelInterface;#[ORM\Entity(repositoryClass: UserRepository::class)]#[ORM\Table(name: "user")]#[UniqueEntity(fields: ['email'],message: 'An account with this email already exists. Try logging in, or reset your password.')]class User implements UserInterface, PasswordAuthenticatedUserInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column(type: "integer")]private ?int $id = null;#[ORM\Column(type: "string", length: 180, unique: true)]private string $email;#[ORM\Column(length: 255, nullable: true)]private ?string $email2 = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $email3 = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $emailVerified = null;#[ORM\ManyToMany(targetEntity: Role::class, inversedBy: 'users')]#[ORM\JoinTable(name: 'user_role')]private Collection $roles;#[ORM\Column(type: 'string')]private string $password;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $salutation = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $firstName = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $lastName = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $fullName = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $mobile = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $mobile2 = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $plainPassword = null;#[ORM\OneToMany(targetEntity: Log::class, mappedBy: 'user', orphanRemoval: true)]private Collection $logs;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $company = null;#[ORM\Column(type: 'date', nullable: true)]private ?\DateTimeInterface $birthday = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $webPage = null;#[ORM\Column(type: 'text', nullable: true)]private ?string $notes = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $jobTitle = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $linkedIn = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $businessPhone = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $businessStreet = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $businessCity = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $businessPostalCode = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $businessCountry = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $homePhone = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $homePhone2 = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $homeStreet = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $homeCity = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $homePostalCode = null;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $homeCountry = null;#[ORM\ManyToOne]private ?Languages $defaultLanguage = null;#[ORM\Column(length: 255, nullable: true)]private ?string $photo = null;#[ORM\ManyToOne(inversedBy: 'recipient')]private ?ClientEmailsSent $clientEmailsSent = null;/*** Inverse side of the ManyToMany with PhotoLocations::enabledUsers*/#[ORM\ManyToMany(targetEntity: PhotoLocations::class, mappedBy: 'enabledUsers')]private Collection $photoLocations;#[ORM\Column(length: 255, nullable: true)]private ?string $autoLoginURL = null;#[ORM\Column(type: "boolean", nullable: true, options: ["default" => false])]private ?bool $pauseForBookmark = null;public function __construct(){$this->roles = new ArrayCollection();$this->logs = new ArrayCollection();$this->photoLocations = new ArrayCollection();}// ---------- ID ----------public function getId(): ?int{return $this->id;}// ---------- Identity / Auth ----------public function getUserIdentifier(): string{return $this->email ?? '';}public function getEmail(): ?string{return $this->email ?? '';}public function setEmail(string $email): self{// normalize for consistent uniqueness$this->email = mb_strtolower(trim($email));return $this;}public function getUsername(): string{return (string) $this->email;}public function getPassword(): string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}public function getSalt(): ?string{return null;}public function eraseCredentials(): void{// clear temp sensitive data if any}// ---------- Roles ----------public function addRole(Role $role): self{if (!$this->roles->contains($role)) {$this->roles->add($role);}return $this;}public function removeRole(Role $role): self{$this->roles->removeElement($role);return $this;}public function getRoles(): array{$roles = $this->roles->toArray();$roleStrings = array_map(fn($r) => $r->getCode(), $roles);$roleStrings[] = 'ROLE_USER';return array_unique($roleStrings);}public function setRoleEntities(iterable $roles): self{$rolesArray = is_array($roles) ? $roles : iterator_to_array($roles);foreach ($this->roles as $existingRole) {if (!in_array($existingRole, $rolesArray, true)) {$this->roles->removeElement($existingRole);}}foreach ($rolesArray as $role) {if (!$this->roles->contains($role)) {$this->roles->add($role);}}return $this;}public function getRoleEntities(): Collection{return $this->roles;}// ---------- Profile fields ----------public function getSalutation(): ?string { return $this->salutation; }public function setSalutation(?string $salutation): self { $this->salutation = $salutation; return $this; }public function getFirstName(): ?string { return $this->firstName; }public function setFirstName(?string $firstName): self { $this->firstName = $firstName; return $this; }public function getLastName(): ?string { return $this->lastName; }public function setLastName(?string $lastName): self { $this->lastName = $lastName; return $this; }public function getFullName(): ?string{return $this->fullName ?? ($this->getFirstName() . ' ' . $this->getLastName());}public function setFullName(?string $fullName): self { $this->fullName = $fullName; return $this; }public function getMobile(): ?string { return $this->mobile; }public function setMobile(?string $mobile): self { $this->mobile = $mobile; return $this; }public function getMobile2(): ?string { return $this->mobile2; }public function setMobile2(?string $mobile2): self { $this->mobile2 = $mobile2; return $this; }public function getPlainPassword(): ?string { return $this->plainPassword; }public function setPlainPassword(?string $plainPassword): self { $this->plainPassword = $plainPassword; return $this; }// put near your other accessorspublic function getEmail2(): ?string{return $this->email2;}public function setEmail2(?string $email2): self{$this->email2 = $email2;return $this;}public function getEmail3(): ?string{return $this->email3;}public function setEmail3(?string $email3): self{$this->email3 = $email3;return $this;}// ---------- Logs ----------public function getLogs(): Collection { return $this->logs; }public function addLog(Log $log): self{if (!$this->logs->contains($log)) {$this->logs->add($log);$log->setUser($this);}return $this;}public function removeLog(Log $log): self{if ($this->logs->removeElement($log)) {if ($log->getUser() === $this) {$log->setUser(null);}}return $this;}// ---------- Misc profile ----------public function getCompany(): ?string { return $this->company; }public function setCompany(?string $company): self { $this->company = $company; return $this; }public function getBirthday(): ?\DateTimeInterface { return $this->birthday; }public function setBirthday(?\DateTimeInterface $birthday): self { $this->birthday = $birthday; return $this; }public function getWebPage(): ?string { return $this->webPage; }public function setWebPage(?string $webPage): self { $this->webPage = $webPage; return $this; }public function getNotes(): ?string { return $this->notes; }public function setNotes(?string $notes): self { $this->notes = $notes; return $this; }public function getJobTitle(): ?string { return $this->jobTitle; }public function setJobTitle(?string $jobTitle): self { $this->jobTitle = $jobTitle; return $this; }public function getLinkedIn(): ?string { return $this->linkedIn; }public function setLinkedIn(?string $linkedIn): self { $this->linkedIn = $linkedIn; return $this; }public function getBusinessPhone(): ?string { return $this->businessPhone; }public function setBusinessPhone(?string $businessPhone): self { $this->businessPhone = $businessPhone; return $this; }public function getBusinessStreet(): ?string { return $this->businessStreet; }public function setBusinessStreet(?string $businessStreet): self { $this->businessStreet = $businessStreet; return $this; }public function getBusinessCity(): ?string { return $this->businessCity; }public function setBusinessCity(?string $businessCity): self { $this->businessCity = $businessCity; return $this; }public function getBusinessPostalCode(): ?string { return $this->businessPostalCode; }public function setBusinessPostalCode(?string $businessPostalCode): self { $this->businessPostalCode = $businessPostalCode; return $this; }public function getBusinessCountry(): ?string { return $this->businessCountry; }public function setBusinessCountry(?string $businessCountry): self { $this->businessCountry = $businessCountry; return $this; }public function getHomePhone(): ?string { return $this->homePhone; }public function setHomePhone(?string $homePhone): self { $this->homePhone = $homePhone; return $this; }public function getHomePhone2(): ?string { return $this->homePhone2; }public function setHomePhone2(?string $homePhone2): self { $this->homePhone2 = $homePhone2; return $this; }public function getHomeStreet(): ?string { return $this->homeStreet; }public function setHomeStreet(?string $homeStreet): self { $this->homeStreet = $homeStreet; return $this; }public function getHomeCity(): ?string { return $this->homeCity; }public function setHomeCity(?string $homeCity): self { $this->homeCity = $homeCity; return $this; }public function getHomePostalCode(): ?string { return $this->homePostalCode; }public function setHomePostalCode(?string $homePostalCode): self { $this->homePostalCode = $homePostalCode; return $this; }public function getHomeCountry(): ?string { return $this->homeCountry; }public function setHomeCountry(?string $homeCountry): self { $this->homeCountry = $homeCountry; return $this; }// ---------- Photo Locations (inverse side) ----------/** @return Collection<int, PhotoLocations> */public function getPhotoLocations(): Collection{return $this->photoLocations;}public function addPhotoLocation(PhotoLocations $photoLocation): self{if (!$this->photoLocations->contains($photoLocation)) {$this->photoLocations->add($photoLocation);// sync owning side$photoLocation->addEnabledUser($this);}return $this;}public function removePhotoLocation(PhotoLocations $photoLocation): self{if ($this->photoLocations->removeElement($photoLocation)) {// sync owning side$photoLocation->removeEnabledUser($this);}return $this;}// ---------- Misc ----------public function getEmailVerified(): ?bool { return $this->emailVerified; }public function setEmailVerified(?bool $emailVerified): self { $this->emailVerified = $emailVerified; return $this; }public function getDefaultLanguage(): ?Languages { return $this->defaultLanguage; }public function setDefaultLanguage(?Languages $defaultLanguage): static { $this->defaultLanguage = $defaultLanguage; return $this; }public function getPhoto(): ?string { return $this->photo; }public function setPhoto(?string $photo): static { $this->photo = $photo; return $this; }public function getClientEmailsSent(): ?ClientEmailsSent { return $this->clientEmailsSent; }public function setClientEmailsSent(?ClientEmailsSent $clientEmailsSent): static { $this->clientEmailsSent = $clientEmailsSent; return $this; }public static function getAvailableRoles(KernelInterface $kernel): array{$rolesFilePath = $kernel->getProjectDir() . '/config/roles.yaml';if (file_exists($rolesFilePath)) {$rolesConfig = Yaml::parseFile($rolesFilePath);return $rolesConfig['roles'] ?? [];}return [];}public function hasRole(Role $role): bool{return $this->roles->contains($role);}public function getAutoLoginURL(): ?string { return $this->autoLoginURL; }public function setAutoLoginURL(?string $autoLoginURL): static { $this->autoLoginURL = $autoLoginURL; return $this; }public function isPauseForBookmark(): bool { return (bool) $this->pauseForBookmark; }public function setPauseForBookmark(bool $pause): self { $this->pauseForBookmark = $pause; return $this; }}