src/Entity/AppUser.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AppUserRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. /**
  10.  * @ORM\Entity(repositoryClass=AppUserRepository::class)
  11.  * @ORM\HasLifecycleCallbacks()
  12.  */
  13. class AppUser implements UserInterface, PasswordAuthenticatedUserInterface
  14. {
  15.     /**
  16.     * @Gedmo\Slug(fields={"username"})
  17.     * @ORM\Column(length=128, unique=true)
  18.     */
  19.     private $slugUsername;
  20.     
  21.     /**
  22.      * @ORM\OneToOne(targetEntity="\App\Entity\Photo", cascade={"persist", "remove"})
  23.      */
  24.     private $avatar;
  25.     
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue
  29.      * @ORM\Column(type="integer")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\Column(type="string", length=180, unique=true)
  34.      */
  35.     private $email;
  36.     /**
  37.      * @ORM\Column(type="string", length=255, unique=true)
  38.      */
  39.     private $username;
  40.     /**
  41.      * @ORM\Column(type="json")
  42.      */
  43.     private $roles = [];
  44.     /**
  45.      * @var string The hashed password
  46.      * @ORM\Column(type="string")
  47.      */
  48.     private $password;
  49.     
  50.      /**
  51.      * @var string
  52.      *
  53.      * @ORM\Column(name="nom", type="string", length=255, nullable=true)
  54.      */
  55.     private $nom;
  56.     
  57.     /**
  58.      * @var string
  59.      *
  60.      * @ORM\Column(name="code", type="string", length=50, nullable=true)
  61.      */
  62.     private $code;
  63.     /**
  64.      * @var string
  65.      *
  66.      * @ORM\Column(name="nom_pere", type="string", length=255, nullable=true)
  67.      */
  68.     private $nomPere;
  69.     
  70.     /**
  71.      * @var string
  72.      *
  73.      * @ORM\Column(name="nom_mere", type="string", length=255, nullable=true)
  74.      */
  75.     private $nomMere;
  76.     
  77.     /**
  78.      * @var string
  79.      *
  80.      * @ORM\Column(name="lieu_de_naissance", type="string", length=255, nullable=true)
  81.      */
  82.     private $lieuDeNaissance;
  83.     /**
  84.      * @var string
  85.      *
  86.      * @ORM\Column(name="date_naissance", type="datetime", nullable=true)
  87.      */
  88.     private $dateNaissance;
  89.     
  90.     /**
  91.      * @var string
  92.      *
  93.      * @ORM\Column(name="inscrit_le", type="datetime", nullable=true)
  94.      */
  95.     private $inscritLe;
  96.     
  97.     /**
  98.      * @var string
  99.      *
  100.      * @ORM\Column(name="date_fin_scolarite", type="datetime", nullable=true)
  101.      */
  102.     private $dateFinScolarite;
  103.     
  104.     /**
  105.      * @var string
  106.      *
  107.      * @ORM\Column(name="numero_jugement_suppletif", type="string", length=10, nullable=true)
  108.      */
  109.     private $numeroJugementSuppletif;
  110.     
  111.     /**
  112.      * @var string
  113.      *
  114.      * @ORM\Column(name="date_jugement_suppletif", type="datetime", nullable=true)
  115.      */
  116.     private $dateJugementSuppletif;
  117.     
  118.     /**
  119.      * @var string
  120.      *
  121.      * @ORM\Column(name="numero_extrait", type="string", length=10, nullable=true)
  122.      */
  123.     private $numeroExtrait;
  124.     
  125.     /**
  126.      * @var string
  127.      *
  128.      * @ORM\Column(name="date_extrait", type="datetime", nullable=true)
  129.      */
  130.     private $dateExtrait;
  131.     
  132.     /**
  133.      * @var string
  134.      *
  135.      * @ORM\Column(name="prenom", type="string", length=255, nullable=true)
  136.      */
  137.     private $prenom;
  138.     /**
  139.      * @var string
  140.      *
  141.      * @ORM\Column(name="sexe", type="string", length=10, nullable=true)
  142.      */
  143.     private $sexe;
  144.     /**
  145.      * @var string
  146.      *
  147.      * @ORM\Column(name="nationalite", type="string", length=255, nullable=true)
  148.      */
  149.     private $nationalite;
  150.      
  151.     /**
  152.      * @var string
  153.      *
  154.      * @ORM\Column(name="matricule_national", type="string", length=255, nullable=true)
  155.      */
  156.     private $matriculeNational;
  157.     
  158.     /**
  159.      * @var boolean
  160.      *
  161.      * @ORM\Column(name="est_etudiant", type="boolean", nullable=true)
  162.      */
  163.     private $estEtudiant;
  164.     
  165.     /**
  166.      * @var string
  167.      *
  168.      * @ORM\Column(name="matriculeInterne", type="string", length=255, nullable=true)
  169.      */
  170.     private $matriculeInterne;
  171.     /**
  172.      * @var string
  173.      *
  174.      * @ORM\Column(name="telephone", type="string", length=255, nullable=true)
  175.      */
  176.     private $telephone;
  177.     
  178.     /**
  179.      * @var string
  180.      *
  181.      * @ORM\Column(name="nom_complet", type="string", length=255, nullable=true)
  182.      */
  183.     private $nomComplet;
  184.     
  185.     
  186.     /**
  187.      * @var string
  188.      */
  189.     private $plainPassword;
  190.      /**
  191.      * Constructor
  192.      */
  193.     public function __construct()
  194.     {
  195.         $this->roles = array("ROLE_USER");
  196.         $this->versements = new ArrayCollection();
  197.         $this->estEtudiant = true;
  198.         $p = new Photo;
  199.         $p->setUrl('image/male-user.png');
  200.         $p->setAlt('Photo de profile');
  201.         $this->avatar = $p;
  202.         $this->inscritLe = new \DateTime();
  203.     }
  204.     public function getId(): ?int
  205.     {
  206.         return $this->id;
  207.     }
  208.     public function getEmail(): ?string
  209.     {
  210.         return $this->email;
  211.     }
  212.     public function setEmail(string $email): self
  213.     {
  214.         $this->email = $email;
  215.         return $this;
  216.     }
  217.     /**
  218.      * A visual identifier that represents this user.
  219.      *
  220.      * @see UserInterface
  221.      */
  222.     public function getUserIdentifier(): string
  223.     {
  224.         return (string) $this->email;
  225.     }
  226.     /**
  227.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  228.      */
  229.     public function getUsername(): string
  230.     {
  231.         return (string) $this->username;
  232.     }
  233.     /**
  234.      * @see UserInterface
  235.      */
  236.     public function getRoles(): array
  237.     {
  238.         $roles = $this->roles;
  239.         // guarantee every user at least has ROLE_USER
  240.         $roles[] = 'ROLE_USER';
  241.         return array_unique($roles);
  242.     }
  243.     public function setRoles(array $roles): self
  244.     {
  245.         $this->roles = $roles;
  246.         return $this;
  247.     }
  248.     /**
  249.      * @see PasswordAuthenticatedUserInterface
  250.      */
  251.     public function getPassword(): string
  252.     {
  253.         return $this->password;
  254.     }
  255.     public function setPassword(string $password): self
  256.     {
  257.         $this->password = $password;
  258.         return $this;
  259.     }
  260.     /**
  261.      * Returning a salt is only needed, if you are not using a modern
  262.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  263.      *
  264.      * @see UserInterface
  265.      */
  266.     public function getSalt(): ?string
  267.     {
  268.         return null;
  269.     }
  270.     /**
  271.      * @see UserInterface
  272.      */
  273.     public function eraseCredentials()
  274.     {
  275.         // If you store any temporary, sensitive data on the user, clear it here
  276.         // $this->plainPassword = null;
  277.     }
  278.     public function getNom(): ?string
  279.     {
  280.         return $this->nom;
  281.     }
  282.     public function setNom(?string $nom): self
  283.     {
  284.         $this->nom = $nom;
  285.         return $this;
  286.     }
  287.     public function getCode(): ?string
  288.     {
  289.         return $this->code;
  290.     }
  291.     public function setCode(?string $code): self
  292.     {
  293.         $this->code = $code;
  294.         return $this;
  295.     }
  296.     public function getNomPere(): ?string
  297.     {
  298.         return $this->nomPere;
  299.     }
  300.     public function setNomPere(?string $nomPere): self
  301.     {
  302.         $this->nomPere = $nomPere;
  303.         return $this;
  304.     }
  305.     public function getNomMere(): ?string
  306.     {
  307.         return $this->nomMere;
  308.     }
  309.     public function setNomMere(?string $nomMere): self
  310.     {
  311.         $this->nomMere = $nomMere;
  312.         return $this;
  313.     }
  314.     public function getLieuDeNaissance(): ?string
  315.     {
  316.         return $this->lieuDeNaissance;
  317.     }
  318.     public function setLieuDeNaissance(?string $lieuDeNaissance): self
  319.     {
  320.         $this->lieuDeNaissance = $lieuDeNaissance;
  321.         return $this;
  322.     }
  323.     public function getDateNaissance(): ?\DateTimeInterface
  324.     {
  325.         return $this->dateNaissance;
  326.     }
  327.     public function setDateNaissance(?\DateTimeInterface $dateNaissance): self
  328.     {
  329.         $this->dateNaissance = $dateNaissance;
  330.         return $this;
  331.     }
  332.     public function getInscritLe(): ?\DateTimeInterface
  333.     {
  334.         return $this->inscritLe;
  335.     }
  336.     public function setInscritLe(?\DateTimeInterface $inscritLe): self
  337.     {
  338.         $this->inscritLe = $inscritLe;
  339.         return $this;
  340.     }
  341.     public function getDateFinScolarite(): ?\DateTimeInterface
  342.     {
  343.         return $this->dateFinScolarite;
  344.     }
  345.     public function setDateFinScolarite(?\DateTimeInterface $dateFinScolarite): self
  346.     {
  347.         $this->dateFinScolarite = $dateFinScolarite;
  348.         return $this;
  349.     }
  350.     public function getNumeroJugementSuppletif(): ?string
  351.     {
  352.         return $this->numeroJugementSuppletif;
  353.     }
  354.     public function setNumeroJugementSuppletif(?string $numeroJugementSuppletif): self
  355.     {
  356.         $this->numeroJugementSuppletif = $numeroJugementSuppletif;
  357.         return $this;
  358.     }
  359.     public function getDateJugementSuppletif(): ?\DateTimeInterface
  360.     {
  361.         return $this->dateJugementSuppletif;
  362.     }
  363.     public function setDateJugementSuppletif(?\DateTimeInterface $dateJugementSuppletif): self
  364.     {
  365.         $this->dateJugementSuppletif = $dateJugementSuppletif;
  366.         return $this;
  367.     }
  368.     public function getNumeroExtrait(): ?string
  369.     {
  370.         return $this->numeroExtrait;
  371.     }
  372.     public function setNumeroExtrait(?string $numeroExtrait): self
  373.     {
  374.         $this->numeroExtrait = $numeroExtrait;
  375.         return $this;
  376.     }
  377.     public function getDateExtrait(): ?\DateTimeInterface
  378.     {
  379.         return $this->dateExtrait;
  380.     }
  381.     public function setDateExtrait(?\DateTimeInterface $dateExtrait): self
  382.     {
  383.         $this->dateExtrait = $dateExtrait;
  384.         return $this;
  385.     }
  386.     public function getPrenom(): ?string
  387.     {
  388.         return $this->prenom;
  389.     }
  390.     public function setPrenom(?string $prenom): self
  391.     {
  392.         $this->prenom = $prenom;
  393.         return $this;
  394.     }
  395.     public function getSexe(): ?string
  396.     {
  397.         return $this->sexe;
  398.     }
  399.     public function setSexe(?string $sexe): self
  400.     {
  401.         $this->sexe = $sexe;
  402.         return $this;
  403.     }
  404.     public function getMatriculeNational(): ?string
  405.     {
  406.         return $this->matriculeNational;
  407.     }
  408.     public function setMatriculeNational(?string $matriculeNational): self
  409.     {
  410.         $this->matriculeNational = $matriculeNational;
  411.         return $this;
  412.     }
  413.     public function isEstEtudiant(): ?bool
  414.     {
  415.         return $this->estEtudiant;
  416.     }
  417.     public function setEstEtudiant(?bool $estEtudiant): self
  418.     {
  419.         $this->estEtudiant = $estEtudiant;
  420.         return $this;
  421.     }
  422.     public function getMatriculeInterne(): ?string
  423.     {
  424.         return $this->matriculeInterne;
  425.     }
  426.     public function setMatriculeInterne(?string $matriculeInterne): self
  427.     {
  428.         $this->matriculeInterne = $matriculeInterne;
  429.         return $this;
  430.     }
  431.     public function getTelephone(): ?string
  432.     {
  433.         return $this->telephone;
  434.     }
  435.     public function setTelephone(?string $telephone): self
  436.     {
  437.         $this->telephone = $telephone;
  438.         return $this;
  439.     }
  440.     public function getNomComplet(): ?string
  441.     {
  442.         return $this->nomComplet;
  443.     }
  444.     public function setNomComplet(?string $nomComplet): self
  445.     {
  446.         $this->nomComplet = $nomComplet;
  447.         return $this;
  448.     }
  449.     
  450.     /**
  451.      * 
  452.      */
  453.     public function getPlainPassword(): string
  454.     {
  455.         return $this->plainPassword;
  456.     }
  457.     public function setPlainPassword(string $plainPassword): self
  458.     {
  459.         $this->plainPassword = $plainPassword;
  460.         return $this;
  461.     }
  462.     public function setUsername(string $username): self
  463.     {
  464.         $this->username = $username;
  465.         return $this;
  466.     }
  467.     public function getAvatar(): ?Photo
  468.     {
  469.         return $this->avatar;
  470.     }
  471.     public function setAvatar(?Photo $avatar): self
  472.     {
  473.         $this->avatar = $avatar;
  474.         return $this;
  475.     }
  476.     public function getSlugUsername(): ?string
  477.     {
  478.         return $this->slugUsername;
  479.     }
  480.     public function setSlugUsername(string $slugUsername): self
  481.     {
  482.         $this->slugUsername = $slugUsername;
  483.         return $this;
  484.     }
  485.     public function getNationalite(): ?string
  486.     {
  487.         return $this->nationalite;
  488.     }
  489.     public function setNationalite(?string $nationalite): self
  490.     {
  491.         $this->nationalite = $nationalite;
  492.         return $this;
  493.     }
  494.     /**
  495.      *@ORM\PreUpdate
  496.      */
  497.     public function preUpdateClasse()
  498.     {
  499.         $this->nomComplet = $this->nom.' '.$this->prenom;
  500.     }
  501.     
  502.     /**
  503.     * @ORM\PrePersist
  504.     */
  505.     
  506.     public function prePersistClasse()
  507.     {
  508.         $this->nomComplet = $this->nom.' '.$this->prenom;
  509.     }
  510.     
  511. }