The user roles */ #[ORM\Column(name: 'roles')] private array $roles = []; /** * @var ?string The hashed password */ #[ORM\Column(name: 'password')] private ?string $password = null; #[ORM\Column(length: 255, name: 'email_quota')] private ?string $emailQuota = null; #[ORM\Column(length: 255, name: 'alternate_email')] private ?string $alternateEmail = null; #[ORM\Column(length: 255, name: 'identifiant_kaz')] private ?string $identifiantKaz = null; #[ORM\Column(length: 255, name: 'quota')] private ?string $quota = null; #[ORM\Column(name: 'has_nextcloud_access')] private ?bool $hasNextcloudAccess = null; #[ORM\Column(length: 255, name: 'nextcloud_quota')] private ?string $nextcloudQuota = null; #[ORM\Column(name: 'has_mobilizon')] private ?bool $hasMobilizon = null; #[ORM\Column(name: 'has_agora_access')] private ?bool $hasAgoraAccess = null; #[ORM\Column(length: 255, name: 'last_name')] private ?string $lastName = null; #[ORM\Column(length: 255, name: 'first_name')] private ?string $firstName = null; #[ORM\Column(length: 255, nullable: true, name: 'image')] private ?string $image = null; #[ORM\Column(length: 20, nullable: true, name: 'telephone')] private ?string $telephone = null; private ?string $numeroMembre = null; private ?bool $mailEnabled = null; private ?string $mailAlias = null; public function __construct() { $this->emailQuota = self::EMAIL_QUOTA_DEFAULT; } public function getId(): ?Uuid { return $this->id; } public function setId(Uuid $id): static { $this->id = $id; return $this; } public function getEmail(): ?string { return $this->email; } public function setEmail(string $email): static { $this->email = $email; return $this; } /** * A visual identifier that represents this user. * * @see UserInterface */ public function getUserIdentifier(): string { return (string) $this->email; } /** * @see UserInterface */ public function getRoles(): array { $roles = $this->roles; $roles[] = 'ROLE_USER'; // garantit qu'il a au moins ce rôle return array_unique($roles); } /** * @param list $roles */ public function setRoles(array $roles): static { $this->roles = $roles; return $this; } /** * @see UserInterface * Ajout de cette fonction, car obligatoire pour faire fonctionner UserInterface correctement */ public function eraseCredentials(): void { // Si vous stockez des données temporaires sensibles sur l'utilisateur, nettoyez-les ici // $this->plainPassword = null; } /** * @see PasswordAuthenticatedUserInterface */ public function getPassword(): ?string { return $this->password; } public function setPassword(string $password): static { $this->password = $password; return $this; } /** * Ensure the session doesn't contain actual password hashes by CRC32C-hashing them, as supported since Symfony 7.3. */ public function __serialize(): array { $data = (array) $this; $data["\0".self::class."\0password"] = hash('crc32c', $this->password); return $data; } public function getEmailQuota(): ?string { return $this->emailQuota; } public function setEmailQuota(string $emailQuota): static { $this->emailQuota = $emailQuota; return $this; } public function getAlternateEmail(): ?string { return $this->alternateEmail; } public function setAlternateEmail(string $alternateEmail): static { $this->alternateEmail = $alternateEmail; return $this; } public function getIdentifiantKaz(): ?string { return $this->identifiantKaz; } public function setIdentifiantKaz(string $identifiantKaz): static { $this->identifiantKaz = $identifiantKaz; return $this; } public function getQuota(): ?string { return $this->quota; } public function setQuota(string $quota): static { $this->quota = $quota; return $this; } public function hasNextcloudAccess(): ?bool { return $this->hasNextcloudAccess; } public function setHasNextcloudAccess(bool $hasNextcloudAccess): static { $this->hasNextcloudAccess = $hasNextcloudAccess; return $this; } public function getNextcloudQuota(): ?string { return $this->nextcloudQuota; } public function setNextcloudQuota(string $nextcloudQuota): static { $this->nextcloudQuota = $nextcloudQuota; return $this; } public function hasMobilizon(): ?bool { return $this->hasMobilizon; } public function setHasMobilizon(bool $hasMobilizon): static { $this->hasMobilizon = $hasMobilizon; return $this; } public function hasAgoraAccess(): ?bool { return $this->hasAgoraAccess; } public function setHasAgoraAccess(bool $hasAgoraAccess): static { $this->hasAgoraAccess = $hasAgoraAccess; return $this; } public function getLastName(): ?string { return $this->lastName; } public function setLastName(string $lastName): static { $this->lastName = $lastName; return $this; } public function getFirstName(): ?string { return $this->firstName; } public function setFirstName(string $firstName): static { $this->firstName = $firstName; return $this; } public function getImage(): ?string { return $this->image; } public function setImage(?string $image): static { $this->image = $image; return $this; } public function getTelephone(): ?string { return $this->telephone; } public function setTelephone(?string $telephone): static { $this->telephone = $telephone; return $this; } public function getNumeroMembre(): ?string { return $this->numeroMembre; } public function setNumeroMembre(?string $numeroMembre): static { $this->numeroMembre = $numeroMembre; return $this; } public function isMailEnabled(): ?bool { return $this->mailEnabled; } public function setMailEnabled(?bool $mailEnabled): static { $this->mailEnabled = $mailEnabled; return $this; } public function getMailAlias(): ?string { return $this->mailAlias; } public function setMailAlias(?string $mailAlias): static { $this->mailAlias = $mailAlias; return $this; } // Fonction qui permet d'afficher les données de l'API sur la page de profil public function updateFromKazUser($kazUser) : User { // Récupération et conversion des données de l'API pour les afficher $this->setEmail($kazUser['mail']); // Création du firstname et lastname (une seule donnée sur l'API) $name = explode(' ', $kazUser['sn']); $this->setFirstName($name[0]); // Récupération des valeurs du tableau moins la première $aLastname = array_slice($name, 1); $this->setLastName(implode(' ', $aLastname)); // Récupération du mail de secours $this->setAlternateEmail($kazUser['mailDeSecours']); $this->setEmailQuota($kazUser['mailQuota']); $this->setHasAgoraAccess($kazUser['agoraEnabled']); $this->setHasMobilizon($kazUser['mobilizonEnabled']); $this->setHasNextcloudAccess($kazUser['nextcloudEnabled']); $this->setNextcloudQuota($kazUser['nextcloudQuota']); $this->setQuota($kazUser['quota']); $this->setIdentifiantKaz($kazUser['identifiantKaz']); return $this; } // Fonction qui permet de convertir les données de l'API vers $kazUser public function convertToKazUser() : array { $data = [ 'numeroMembre' => $this->getNumeroMembre(), 'mailDeSecours' => $this->getAlternateEmail(), 'mailEnabled' => $this->isMailEnabled(), 'nextcloudEnabled' => $this->hasNextcloudAccess(), 'mobilizonEnabled' => $this->hasMobilizon(), 'agoraEnabled' => $this->hasAgoraAccess(), 'identifiantKaz' => $this->getIdentifiantKaz(), 'mailAlias' => $this->getMailAlias(), 'quota' => $this->getQuota(), ]; return array_filter($data, fn($value) => $value !== null); } }