function countries_country_code_context in Countries 8
Same name and namespace in other branches
- 7.2 plugins/arguments/country_code.inc \countries_country_code_context()
Discover if this argument gives us the term we crave.
1 string reference to 'countries_country_code_context'
- country_code.inc in plugins/
arguments/ country_code.inc - Plugin to provide an argument handler for a country entity.
File
- plugins/
arguments/ country_code.inc, line 27 - Plugin to provide an argument handler for a country entity.
Code
function countries_country_code_context($arg = NULL, $conf = NULL, $empty = FALSE) {
// If unset it wants a generic, unfilled context.
if ($empty) {
return ctools_context_create_empty('entity:country');
}
// We can accept either a country entity or a pure nid.
if (is_object($arg)) {
return ctools_context_create('entity:country', $arg);
}
// A very generic country lookup is done here.
// This will fallback to names, etc, but only ISO codes are really safe.
if ($country = countries_country_lookup($arg)) {
return ctools_context_create('entity:country', $country);
}
return FALSE;
}