当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::fromId方法代码示例

本文整理汇总了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;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:15,代码来源:Notice_location.php

示例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;
 }
开发者ID:a780201,项目名称:gnu-social,代码行数:35,代码来源:Notice.php

示例3: testLocationFromId

 /**
  * @dataProvider locationIds
  */
 public function testLocationFromId($id, $ns, $language, $location)
 {
     $result = Location::fromId($id, $ns, $language);
     $this->assertEquals($result, $location);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:8,代码来源:LocationTest.php

示例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;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:20,代码来源:Profile.php


注:本文中的Location::fromId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。