123456789101112131415161718192021222324252627282930 |
- <?php
- namespace WorkflowBundle\Validator;
- use Symfony\Component\Validator\Context\ExecutionContextInterface;
- use WorkflowBundle\Utils\DoctrineEvents;
- use WorkflowBundle\Utils\WorkFlowEvents;
- use WorkflowBundle\Entity\Action;
- class EventFieldsValidator
- {
- /**
- * @param string $value
- * @param ExecutionContextInterface $context
- * @param array $payload
- */
- public static function validate($value, ExecutionContextInterface $context, $payload)
- {
- /* @var $entity Action */
- $entity = $context->getObject();
- $class = isset($payload['doctrine']) ? DoctrineEvents::class : WorkFlowEvents::class;
- if (!empty(array_intersect($entity->getEvent(), $class::getChoices())) && is_null($value)) {
- $context->buildViolation('error.event_field_required')
- ->addViolation()
- ;
- }
- }
- }
|