comparison vendor/symfony/validator/Constraints/ImageValidator.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
32 { 32 {
33 if (!$constraint instanceof Image) { 33 if (!$constraint instanceof Image) {
34 throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Image'); 34 throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Image');
35 } 35 }
36 36
37 $violations = count($this->context->getViolations()); 37 $violations = \count($this->context->getViolations());
38 38
39 parent::validate($value, $constraint); 39 parent::validate($value, $constraint);
40 40
41 $failed = count($this->context->getViolations()) !== $violations; 41 $failed = \count($this->context->getViolations()) !== $violations;
42 42
43 if ($failed || null === $value || '' === $value) { 43 if ($failed || null === $value || '' === $value) {
44 return; 44 return;
45 } 45 }
46 46
215 ->setCode(Image::PORTRAIT_NOT_ALLOWED_ERROR) 215 ->setCode(Image::PORTRAIT_NOT_ALLOWED_ERROR)
216 ->addViolation(); 216 ->addViolation();
217 } 217 }
218 218
219 if ($constraint->detectCorrupted) { 219 if ($constraint->detectCorrupted) {
220 if (!function_exists('imagecreatefromstring')) { 220 if (!\function_exists('imagecreatefromstring')) {
221 throw new RuntimeException('Corrupted images detection requires installed and enabled GD extension'); 221 throw new RuntimeException('Corrupted images detection requires installed and enabled GD extension');
222 } 222 }
223 223
224 $resource = @imagecreatefromstring(file_get_contents($value)); 224 $resource = @imagecreatefromstring(file_get_contents($value));
225 225