src/Form/Models/ContactPubFusacqExpert.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * @author Raymond
  5.  */
  6. namespace App\Form\Models;
  7. use App\Validator\Constraints\ContainsOnlyAlphabetic;
  8. use App\Validator\Constraints\ContainsOnlyNumeric;
  9. use App\Validator\Constraints\Nom;
  10. use App\Validator\Constraints\PhoneNumber;
  11. use App\Validator\Constraints\Prenom;
  12. use EWZ\Bundle\RecaptchaBundle\Validator\Constraints as Recaptcha;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. use Symfony\Component\Validator\Constraints\IsTrue;
  15. use Symfony\Component\Validator\Mapping\ClassMetadata;
  16. use Symfony\Component\Validator\Constraints\NotBlank;
  17. use App\Validator\Constraints\Message;
  18. class ContactPubFusacqExpert
  19. {
  20.     public $nom;
  21.     public $prenom;
  22.     public $email;
  23.     public $telephone;
  24.     public $indicatif;
  25.     public $societe;
  26.     public $message;
  27.     /**
  28.      * @Recaptcha\IsTrue(message="captcha invalide")
  29.      */
  30.     public $recaptcha;
  31.     public $lang;
  32.     /**
  33.      * @return void
  34.      */
  35.     public static function loadValidatorMetadata(ClassMetadata $metadata)
  36.     {
  37.         $metadata->addPropertyConstraint('telephone', new PhoneNumber());
  38.         $metadata->addPropertyConstraint('nom', new Nom() );
  39.         $metadata->addPropertyConstraint('prenom', new Prenom());
  40.         $metadata->addPropertyConstraint('nom', new NotBlank([  'message' => 'le champ nom est obligatoire'  ]));
  41.         $metadata->addPropertyConstraint('prenom', new NotBlank([  'message' => 'le champ prenom est obligatoire'  ]));
  42.         
  43.         $metadata->addPropertyConstraint('message',new NotBlank(['message' => 'le champ message est obligatoire']));
  44.         $metadata->addPropertyConstraint('message', new Message() );
  45.         
  46.         
  47.         $metadata->addPropertyConstraint('telephone', new NotBlank([  'message' => 'le champ telephone est obligatoire'  ]));
  48.         $metadata->addPropertyConstraint('email', new NotBlank([  'message' => 'le champ email est obligatoire'  ]));
  49.         $metadata->addPropertyConstraint('email', new Assert\Email([  'message' => 'le champ email est invalide'  ]));
  50.         /**
  51.          * renfort de validation: voir ici:
  52.          * https://github.com/jbafford/PasswordStrengthBundle
  53.          */
  54.     }
  55.     /**
  56.      * @param $property
  57.      * @return mixed
  58.      */
  59.     public function _get($property)
  60.     {
  61.         return $this->$property;
  62.     }
  63.     /**
  64.      * Magic setter to save public properties.
  65.      *
  66.      * @param string $property
  67.      * @param mixed  $value
  68.      */
  69.     public function _set($property$value)
  70.     {
  71.         $this->$property $value;
  72.     }
  73. }