CommerceGuys\Addressing\Country\CountryRepositoryInterface::getList PHP Méthode

getList() public méthode

Returns a list of countries.
public getList ( string $locale = null ) : array
$locale string The locale (e.g. fr-FR).
Résultat array An array of country names, keyed by country code.
    public function getList($locale = null);

Usage Example

 /**
  * {@inheritdoc}
  */
 public function validate($value, Constraint $constraint)
 {
     if ($value === null || $value === '') {
         return;
     }
     if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
         throw new UnexpectedTypeException($value, 'string');
     }
     $countries = $this->countryRepository->getList();
     $value = (string) $value;
     if (!isset($countries[$value])) {
         if ($this->context instanceof \Symfony\Component\Validator\Context\ExecutionContextInterface) {
             $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->addViolation();
         } else {
             $this->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->addViolation();
         }
     }
 }
All Usage Examples Of CommerceGuys\Addressing\Country\CountryRepositoryInterface::getList
CountryRepositoryInterface