src/Form/Models/ContactezDirectementExperts.php line 25

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * @author Mehrez Labidi
  5.  * @Description il s'agit d'un modèle pour définir les différents validations utilisés dans le formulaire FormType
  6.  * Ce modèle n'interagit pas avec la base de  données
  7.  */
  8. namespace App\Form\Models;
  9. use App\Helper\Utils;
  10. use App\Validator\Constraints\ContainsOnlyAlphabetic;
  11. use App\Validator\Constraints\ContainsOnlyNumeric;
  12. use App\Validator\Constraints\Nom;
  13. use App\Validator\Constraints\Prenom;
  14. use App\Validator\Constraints\PhoneNumber;
  15. use EWZ\Bundle\RecaptchaBundle\Validator\Constraints as Recaptcha;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. use Symfony\Component\Validator\Constraints\IsTrue;
  18. use Symfony\Component\Validator\Mapping\ClassMetadata;
  19. use Symfony\Component\Validator\Constraints\NotBlank;
  20. use App\Validator\Constraints\Message;
  21. class ContactezDirectementExperts
  22. {
  23.     
  24.     public $nom;
  25.     public $prenom;
  26.     public $mail;
  27.     public $telephone;
  28.     public $indicatif;
  29.     public $societe;
  30.     public $message;
  31.     /**
  32.      * @Recaptcha\IsTrue(message="captcha invalide")
  33.      */
  34.     public $recaptcha;
  35.     
  36.     public $id_service_prestataire;
  37.     public $id_membre;
  38.     public $lang;
  39.     
  40.     public function _get($property)
  41.     {
  42.         return $this->$property;
  43.     }
  44.     
  45.     /**
  46.      * Magic setter to save public properties.
  47.      *
  48.      * @param string $property
  49.      * @param mixed  $value
  50.      */
  51.     public function _set($property$value)
  52.     {
  53.         $this->$property $value;
  54.     }
  55.     
  56.     /**
  57.      * @return mixed
  58.      */
  59.     public function getNom()
  60.     {
  61.         return $this->nom;
  62.     }
  63.     
  64.     /**
  65.      * @param mixed $nom
  66.      */
  67.     public function setNom($nom): void
  68.     {
  69.         $this->nom $nom;
  70.     }
  71.     
  72.     /**
  73.      * @return mixed
  74.      */
  75.     public function getPrenom()
  76.     {
  77.         return $this->prenom;
  78.     }
  79.     
  80.     /**
  81.      * @param mixed $prenom
  82.      */
  83.     public function setPrenom($prenom): void
  84.     {
  85.         $this->prenom $prenom;
  86.     }
  87.     
  88.     /**
  89.      * @return mixed
  90.      */
  91.     public function getMail()
  92.     {
  93.         return $this->mail;
  94.     }
  95.     
  96.     /**
  97.      * @param mixed $mail
  98.      */
  99.     public function setMail($mail): void
  100.     {
  101.         $this->mail $mail;
  102.     }
  103.     
  104.     /**
  105.      * @return mixed
  106.      */
  107.     public function getTelephone()
  108.     {
  109.         return $this->telephone;
  110.     }
  111.     
  112.     /**
  113.      * @param mixed $telephone
  114.      */
  115.     public function setTelephone($telephone): void
  116.     {
  117.         $this->telephone $telephone;
  118.     }
  119.     
  120.     /**
  121.      * @return mixed
  122.      */
  123.     public function getSociete()
  124.     {
  125.         return $this->societe;
  126.     }
  127.     
  128.     /**
  129.      * @param mixed $societe
  130.      */
  131.     public function setSociete($societe): void
  132.     {
  133.         $this->societe $societe;
  134.     }
  135.     
  136.     /**
  137.      * @return mixed
  138.      */
  139.     public function getMessage()
  140.     {
  141.         return $this->message;
  142.     }
  143.     
  144.     /**
  145.      * @param mixed $message
  146.      */
  147.     public function setMessage($message): void
  148.     {
  149.         $this->message $message;
  150.     }
  151.     
  152.     /**
  153.      * @return void
  154.      */
  155.     public static function loadValidatorMetadata(ClassMetadata $metadata)
  156.     {
  157.         $metadata->addPropertyConstraint('telephone', new PhoneNumber());
  158.         $metadata->addPropertyConstraint('nom', new Nom() );
  159.         $metadata->addPropertyConstraint('prenom', new Prenom());
  160.         $metadata->addPropertyConstraint('nom', new NotBlank([  'message' => 'le champ nom est obligatoire'  ]));
  161.         $metadata->addPropertyConstraint('prenom', new NotBlank([  'message' => 'le champ prenom est obligatoire'  ]));
  162.   
  163.         $metadata->addPropertyConstraint('message',new NotBlank(['message' => 'le champ message est obligatoire']));
  164.         $metadata->addPropertyConstraint('message', new Message() );
  165.         
  166.         
  167.         $metadata->addPropertyConstraint('telephone', new NotBlank([  'message' => 'le champ telephone est obligatoire'  ]));
  168.         $metadata->addPropertyConstraint('societe', new NotBlank([  'message' => 'le champ societe est obligatoire'  ]));
  169.         $metadata->addPropertyConstraint('mail', new NotBlank([  'message' => 'le champ email est obligatoire'  ]));
  170.         $metadata->addPropertyConstraint('mail', new Assert\Email([  'message' => 'le champ email est invalide'  ]));
  171.     }
  172.     
  173. }