本文整理匯總了PHP中Symfony\Component\Locale\Locale::getLanguages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Locale::getLanguages方法的具體用法?PHP Locale::getLanguages怎麽用?PHP Locale::getLanguages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Locale\Locale
的用法示例。
在下文中一共展示了Locale::getLanguages方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validate
/**
* {@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::getLanguages())) {
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
}
}
示例2: isValid
public function isValid($value, Constraint $constraint)
{
if (null === $value || '' === $value) {
return true;
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString()'))) {
throw new UnexpectedTypeException($value, 'string');
}
$value = (string) $value;
if (!in_array($value, Locale::getLanguages())) {
$this->setMessage($constraint->message, array('{{ value }}' => $value));
return false;
}
return true;
}
示例3: testGetLanguages
public function testGetLanguages()
{
$languages = Locale::getLanguages();
$this->assertTrue(in_array('pt_BR', $languages));
}
示例4: testGetLanguages
public function testGetLanguages()
{
$languages = Locale::getLanguages();
$this->assertContains('pt_BR', $languages);
}
示例5: getLanguages
public function getLanguages()
{
return json_encode(\Symfony\Component\Locale\Locale::getLanguages());
}