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