|
9 | 9 | use Symfony\Component\Console\Output\OutputInterface;
|
10 | 10 | use Symfony\Component\Validator\ConstraintViolationList;
|
11 | 11 | use Symfony\Component\Validator\Validator;
|
| 12 | +use Symfony\Component\Validator\Constraints as Assert; |
12 | 13 | use Monolog\Handler\StreamHandler;
|
13 | 14 | use Doctrine\ORM\EntityManager;
|
14 | 15 | use Oro\Bundle\BatchBundle\Entity\JobExecution;
|
@@ -75,16 +76,24 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
75 | 76 | );
|
76 | 77 | }
|
77 | 78 |
|
| 79 | + $validator = $this->getValidator(); |
| 80 | + |
78 | 81 | // Override mail notifier recipient email
|
79 | 82 | if ($email = $input->getOption('email')) {
|
| 83 | + if ($errors = $validator->validateValue($email, new Assert\Email())) { |
| 84 | + throw new \RuntimeException( |
| 85 | + sprintf('Email "%s" is invalid: %s', $email, $this->getErrorMessages($errors)) |
| 86 | + ); |
| 87 | + } |
80 | 88 | $this
|
81 | 89 | ->getMailNotifier()
|
82 | 90 | ->setRecipientEmail($email);
|
83 | 91 | }
|
84 | 92 |
|
85 |
| - $errors = $this->getValidator()->validate($jobInstance, array('Default', 'Execution')); |
86 |
| - if (count($errors) > 0) { |
87 |
| - throw new \RuntimeException(sprintf('Job "%s" is invalid: %s', $code, $this->getErrorMessages($errors))); |
| 93 | + if ($errors = $validator->validate($jobInstance, array('Default', 'Execution'))) { |
| 94 | + throw new \RuntimeException( |
| 95 | + sprintf('Job "%s" is invalid: %s', $code, $this->getErrorMessages($errors)) |
| 96 | + ); |
88 | 97 | }
|
89 | 98 |
|
90 | 99 | $executionId = $input->getArgument('execution');
|
|
0 commit comments