git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3447 f459cee4-fb09-11de-96c3-f9c5f16c3c76
87 lines
No EOL
2.8 KiB
PHP
87 lines
No EOL
2.8 KiB
PHP
<?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)
|
|
{
|
|
|
|
for($i = 1; $i < $bookingRequest->getSingleRoomCount(); ++$i)
|
|
{
|
|
$this->context->getValidator()->inContext($this->context)
|
|
->atPath('rooms['.$i.']')
|
|
->validate($bookingRequest->getSingleRooms()[$i])
|
|
;
|
|
}
|
|
for($i = 1; $i < $bookingRequest->getSingleRoomChildCount(); ++$i)
|
|
{
|
|
$this->context->getValidator()->inContext($this->context)
|
|
->atPath('rooms['.($i+3).']')
|
|
->validate($bookingRequest->getSingleChildRooms()[$i])
|
|
;
|
|
}
|
|
for($i = 1; $i < $bookingRequest->getDoubleRoomCount(); ++$i)
|
|
{
|
|
$this->context->getValidator()->inContext($this->context)
|
|
->atPath('rooms['.($i+7).']')
|
|
->validate($bookingRequest->getDoubleRooms()[$i])
|
|
;
|
|
}
|
|
|
|
for($i = 1; $i < $bookingRequest->getDoubleRoomChildCount(); ++$i)
|
|
{
|
|
$this->context->getValidator()->inContext($this->context)
|
|
->atPath('rooms['.($i+10).']')
|
|
->validate($bookingRequest->getDoubleChildRooms()[$i])
|
|
;
|
|
}
|
|
|
|
for($i = 1; $i < $bookingRequest->getTripleRoomCount(); ++$i)
|
|
{
|
|
$this->context->getValidator()->inContext($this->context)
|
|
->atPath('rooms['.($i + 13).']')
|
|
->validate($bookingRequest->getTripleRooms()[$i])
|
|
;
|
|
}
|
|
for($i = 1; $i < $bookingRequest->getTripleRoomChildCount(); ++$i)
|
|
{
|
|
$this->context->getValidator()->inContext($this->context)
|
|
->atPath('rooms['.($i + 15).']')
|
|
->validate($bookingRequest->getTripleChildRooms()[$i])
|
|
;
|
|
}
|
|
}
|
|
} |