Location::fromOptions(Notice::locationOptions(...))
This commit is contained in:
parent
f4309ed715
commit
26a6eca94e
|
@ -56,6 +56,23 @@ class Location
|
||||||
|
|
||||||
var $names = array();
|
var $names = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor that makes a Location from Notice::locationOptions(...)
|
||||||
|
*
|
||||||
|
* @param array $options an array for example provided by Notice::locationOptions(...)
|
||||||
|
*
|
||||||
|
* @return Location Location with the given options (lat, lon, id, name)
|
||||||
|
*/
|
||||||
|
static function fromOptions(array $options) {
|
||||||
|
$location = new Location();
|
||||||
|
foreach (['lat', 'lon', 'location_id', 'location_ns'] as $opt) {
|
||||||
|
if (isset($options[$opt])) {
|
||||||
|
$location->$opt = $options[$opt];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that makes a Location from a string name
|
* Constructor that makes a Location from a string name
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user