Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ostretsov/d38d8f782502eae450a2 to your computer and use it in GitHub Desktop.
Save ostretsov/d38d8f782502eae450a2 to your computer and use it in GitHub Desktop.
<?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