Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/validator/Constraints/LocaleValidator.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
34 | 34 |
35 if (null === $value || '' === $value) { | 35 if (null === $value || '' === $value) { |
36 return; | 36 return; |
37 } | 37 } |
38 | 38 |
39 if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { | 39 if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { |
40 throw new UnexpectedTypeException($value, 'string'); | 40 throw new UnexpectedTypeException($value, 'string'); |
41 } | 41 } |
42 | 42 |
43 $value = (string) $value; | 43 $value = (string) $value; |
44 $locales = Intl::getLocaleBundle()->getLocaleNames(); | 44 $locales = Intl::getLocaleBundle()->getLocaleNames(); |
45 $aliases = Intl::getLocaleBundle()->getAliases(); | 45 $aliases = Intl::getLocaleBundle()->getAliases(); |
46 | 46 |
47 if (!isset($locales[$value]) && !in_array($value, $aliases)) { | 47 if (!isset($locales[$value]) && !\in_array($value, $aliases)) { |
48 $this->context->buildViolation($constraint->message) | 48 $this->context->buildViolation($constraint->message) |
49 ->setParameter('{{ value }}', $this->formatValue($value)) | 49 ->setParameter('{{ value }}', $this->formatValue($value)) |
50 ->setCode(Locale::NO_SUCH_LOCALE_ERROR) | 50 ->setCode(Locale::NO_SUCH_LOCALE_ERROR) |
51 ->addViolation(); | 51 ->addViolation(); |
52 } | 52 } |