src/Form/Models/ContactezNous.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\PhoneNumber;
  14. use App\Validator\Constraints\Prenom;
  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 ContactezNous {
  22.     public $type_contact;
  23.     public $civilite;
  24.     public $nom;
  25.     public $prenom;
  26.     public $email;
  27.     public $telephone;
  28.     public $indicatif;
  29.     public $contenu_question;
  30.     /**
  31.      * @Recaptcha\IsTrue(message="captcha invalide")
  32.      */
  33.     public $recaptcha;
  34.     public $lang;
  35.     public $website//Honeypot
  36.     public $company//Honeypot
  37.     /**
  38.      * @return void
  39.      */
  40.     public static function loadValidatorMetadata(ClassMetadata $metadata) {
  41.         $metadata->addPropertyConstraint('telephone', new PhoneNumber());
  42.         $metadata->addPropertyConstraint('nom', new Nom());
  43.         $metadata->addPropertyConstraint('prenom', new Prenom());
  44.         $metadata->addPropertyConstraint('type_contact', new NotBlank(['message' => 'le type de contact est obligatoire']));
  45.         $metadata->addPropertyConstraint('civilite', new NotBlank(['message' => 'le champ civilite est obligatoire']));
  46.         $metadata->addPropertyConstraint('nom', new NotBlank(['message' => 'le champ nom est obligatoire']));
  47.         $metadata->addPropertyConstraint('prenom', new NotBlank(['message' => 'le champ prenom est obligatoire']));
  48.         $metadata->addPropertyConstraint('contenu_question', new NotBlank(['message' => 'le champ message est obligatoire']));
  49.         $metadata->addPropertyConstraint('contenu_question', new Message());
  50.         $metadata->addPropertyConstraint('telephone', new NotBlank(['message' => 'le champ telephone est obligatoire']));
  51.         $metadata->addPropertyConstraint('email', new NotBlank(['message' => 'le champ email est obligatoire']));
  52.         $metadata->addPropertyConstraint('email', new Assert\Email(['message' => 'le champ email est invalide']));
  53.         /**
  54.          * renfort de validation: voir ici:
  55.          * https://github.com/jbafford/PasswordStrengthBundle
  56.          */
  57.     }
  58.     /**
  59.      * @param $property
  60.      * @return mixed
  61.      */
  62.     public function _get($property) {
  63.         return $this->$property;
  64.     }
  65.     /**
  66.      * Magic setter to save public properties.
  67.      *
  68.      * @param string $property
  69.      * @param mixed  $value
  70.      */
  71.     public function _set($property$value) {
  72.         $this->$property $value;
  73.     }
  74.     /**
  75.      * @return mixed
  76.      */
  77.     public function getContenuQuestion() {
  78.         return $this->contenu_question;
  79.     }
  80.     /**
  81.      * @param mixed $contenu_question
  82.      */
  83.     public function setContenuQuestion($contenu_question): void {
  84.         $this->contenu_question $contenu_question;
  85.     }
  86. }