<?php
/**
 * @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
 * @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')->
    }
}