Created
January 8, 2015 16:52
-
-
Save ostretsov/d38d8f782502eae450a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* (c) Artem Ostretsov <artem@ostretsov.ru> | |
* Created at 15.10.2014 12:32 | |
*/ | |
namespace SP\EventBundle\Validator\Constraints; | |
use SP\EventBundle\Entity\EventRequest; | |
use Symfony\Component\Validator\Constraint; | |
use Symfony\Component\Validator\ConstraintValidator; | |
class EventRequestSectionRequirementValidator extends ConstraintValidator | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function validate($value, Constraint $constraint) | |
{ | |
if ($value instanceof EventRequest) { | |
if (null === $value->getEventSection() && count($value->getEvent()->getSections()) > 0) { | |
$this->buildViolation($constraint->message) | |
->addViolation(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment