function countries_get_countries in Countries 8
Same name and namespace in other branches
- 7.2 countries.module \countries_get_countries()
- 7 countries.module \countries_get_countries()
Helper function to load countries. This includes all countries by default.
This now accepts a list of filters to provide an easy method of returning a filtered list of countries.
Parameters
string $property: A property of the country to return rather than the entire country object. Leave unset or pass in 'all' to have the country objects returned.
array $filters: An array of filters. See countries_filter() for details.
array $options: An array of options. See country_property() for details.
Return value
array An array of countries ordered by name or by the specified property.
11 calls to countries_get_countries()
- CountriesCacheUnitTest::testCache in tests/
countries.test - CountriesFunctionsUnitTest::testCountriesLookupListing in tests/
countries.test - This browes the admin listing, making sure that the countries are correctly listed.
- countries_allowed_values in ./
countries.fields.inc - Returns a set of valid countries of a countries field.
- countries_countries_alter in ./
countries.module - Implements hook_countries_alter().
- countries_country_lookup in ./
countries.module - A helper function to find a country based on any country property.
2 string references to 'countries_get_countries'
- countries_clear_caches in ./
countries.module - Helper function to clear various caches.
- countries_i18n_i18n_object_info in modules/
countries_i18n/ countries_i18n.module - Implements hook_i18n_object_info().
File
- ./
countries.module, line 686 - Defines the field and entity information for countries.
Code
function countries_get_countries($property = 'all', $filters = array(), $options = array()) {
$countries = entity_load_multiple_by_name('country');
$filtered_countries = countries_filter($countries, $filters);
if ($property == 'all' || empty($property)) {
return $filtered_countries;
}
$mapped_countries = array();
foreach ($filtered_countries as $country) {
$mapped_countries[$country->iso2] = country_property($country, $property, $options);
}
uasort($mapped_countries, 'countries_sort');
return $mapped_countries;
}