X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Flocation.php;h=54e0d07acf61575fff990cf2d9f56c8123fabcc6;hb=26a6eca94e0ce90fb6c85c731590a5a32cbd89ab;hp=191550d6d6ca53e213f4a13f3b6b8bd2fc763a65;hpb=f4309ed715bd986caa51ec5428a3b1f32f10957e;p=quix0rs-gnu-social.git diff --git a/lib/location.php b/lib/location.php index 191550d6d6..54e0d07acf 100644 --- a/lib/location.php +++ b/lib/location.php @@ -56,6 +56,23 @@ class Location 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 *