本文整理汇总了PHP中Location::fromId方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::fromId方法的具体用法?PHP Location::fromId怎么用?PHP Location::fromId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location::fromId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: asLocation
public function asLocation()
{
$location = null;
if (!empty($this->location_id) && !empty($this->location_ns)) {
$location = Location::fromId($this->location_id, $this->location_ns);
}
if (is_null($location)) {
// no ID, or Location::fromId() failed
$location = Location::fromLatLon($this->lat, $this->lon);
}
if (is_null($location)) {
throw new ServerException('Location could not be looked up from existing data.');
}
return $location;
}
示例2: locationOptions
static function locationOptions($lat, $lon, $location_id, $location_ns, $profile = null)
{
$options = array();
if (!empty($location_id) && !empty($location_ns)) {
$options['location_id'] = $location_id;
$options['location_ns'] = $location_ns;
$location = Location::fromId($location_id, $location_ns);
if ($location instanceof Location) {
$options['lat'] = $location->lat;
$options['lon'] = $location->lon;
}
} else {
if (!empty($lat) && !empty($lon)) {
$options['lat'] = $lat;
$options['lon'] = $lon;
$location = Location::fromLatLon($lat, $lon);
if ($location instanceof Location) {
$options['location_id'] = $location->location_id;
$options['location_ns'] = $location->location_ns;
}
} else {
if (!empty($profile)) {
if (isset($profile->lat) && isset($profile->lon)) {
$options['lat'] = $profile->lat;
$options['lon'] = $profile->lon;
}
if (isset($profile->location_id) && isset($profile->location_ns)) {
$options['location_id'] = $profile->location_id;
$options['location_ns'] = $profile->location_ns;
}
}
}
}
return $options;
}
示例3: testLocationFromId
/**
* @dataProvider locationIds
*/
public function testLocationFromId($id, $ns, $language, $location)
{
$result = Location::fromId($id, $ns, $language);
$this->assertEquals($result, $location);
}
示例4: getLocation
function getLocation()
{
$location = null;
if (!empty($this->location_id) && !empty($this->location_ns)) {
$location = Location::fromId($this->location_id, $this->location_ns);
}
if (is_null($location)) {
// no ID, or Location::fromId() failed
if (!empty($this->lat) && !empty($this->lon)) {
$location = Location::fromLatLon($this->lat, $this->lon);
}
}
if (is_null($location)) {
// still haven't found it!
if (!empty($this->location)) {
$location = Location::fromName($this->location);
}
}
return $location;
}