Exemplo n.º 1
0
 /**
  * {@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));
     }
 }
Exemplo n.º 2
0
 public function testGetLocales()
 {
     $locales = Locale::getLocales();
     $this->assertTrue(in_array('pt', $locales));
 }
 public function getLocales()
 {
     return json_encode(\Symfony\Component\Locale\Locale::getLocales());
 }
Exemplo n.º 4
0
 public function testGetLocales()
 {
     $locales = Locale::getLocales();
     $this->assertContains('pt', $locales);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function getLanguages()
 {
     return $this->locale->getLocales();
 }