diff --git a/trunk/src/AppBundle/Validator/Constraints/BookingRequest.php b/trunk/src/AppBundle/Validator/Constraints/BookingRequest.php new file mode 100644 index 00000000..65c9829f --- /dev/null +++ b/trunk/src/AppBundle/Validator/Constraints/BookingRequest.php @@ -0,0 +1,21 @@ + + * @date 02/13/2017 + */ + +namespace AppBundle\Validator\Constraints; + + +use Symfony\Component\Validator\Constraint; + +/** + * @Annotation + */ +class BookingRequest extends Constraint +{ + public function getTargets() + { + return self::CLASS_CONSTRAINT; + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Validator/Constraints/BookingRequestValidator.php b/trunk/src/AppBundle/Validator/Constraints/BookingRequestValidator.php new file mode 100644 index 00000000..0528b09d --- /dev/null +++ b/trunk/src/AppBundle/Validator/Constraints/BookingRequestValidator.php @@ -0,0 +1,54 @@ + + * @date 12/16/2016 + */ + +namespace AppBundle\Validator\Constraints; + +use AppBundle\Entity\BookingRequest; +use AppBundle\Entity\TravelDate; +use AppBundle\Entity\TravelProgram; +use AppBundle\Form\BookingRequestType; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; + +/** + * Class BookingRequestValidator + * @package AppBundle\Validator + */ +class BookingRequestValidator extends ConstraintValidator +{ + /* + private $travelDate; + private $travelProgram; + + public function __construct(TravelDate $travelDate, TravelProgram $travelProgram) + { + $this->travelDate = $travelDate; + $this->travelProgram = $travelProgram; + } + */ + + /** + * Checks if the passed value is valid. + * + * @param BookingRequest $bookingRequest The value that should be validated + * @param Constraint $constraint The constraint for the validation + */ + public function validate($bookingRequest, Constraint $constraint) + { + //die($bookingRequest->get); + for ($i = 0; $i < $bookingRequest->getTravelerCount(); ++$i) + { + //$this->context->atPa + $this->context->getValidator()->inContext($this->context) + ->atPath('travelers['. $i .']') + ->validate($bookingRequest->getTravelers()[$i]) + ; + //$this->context->getValidator()->validate($bookingRequest->getTravelers()[$i]); + } + //$this->context->getValidator()->startContext() + //->atPath('travelers')-> + } +} \ No newline at end of file