/** * {@inheritDoc} */ public function validate($value, Constraint $constraint) { if (null === $value || '' === $value) { return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedTypeException($value, 'string'); } $value = (string) $value; if (!in_array($value, \Symfony\Component\Locale\Locale::getLocales())) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); } }
public function testGetLocales() { $locales = Locale::getLocales(); $this->assertTrue(in_array('pt', $locales)); }
public function getLocales() { return json_encode(\Symfony\Component\Locale\Locale::getLocales()); }
public function testGetLocales() { $locales = Locale::getLocales(); $this->assertContains('pt', $locales); }
/** * {@inheritdoc} */ public function getLanguages() { return $this->locale->getLocales(); }