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


PHP Host::fromJSON方法代码示例

本文整理汇总了PHP中Host::fromJSON方法的典型用法代码示例。如果您正苦于以下问题:PHP Host::fromJSON方法的具体用法?PHP Host::fromJSON怎么用?PHP Host::fromJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Host的用法示例。


在下文中一共展示了Host::fromJSON方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: stregistry_ModifyNameserver

/**
 * make request to update host ip addresses
 * 
 * @param array $params whmcs data
 * 
 * @return mixed array containig error message will return if error was ocurred, 'success' string in other case
 */
function stregistry_ModifyNameserver($params)
{
    // init connection
    if (($status = __initConnectionAndAuthorize($params)) !== true) {
        return __errorArray($status);
    }
    $json = STRegistry::Hosts()->query($params['nameserver']);
    if (!ResponseHelper::isSuccess($json)) {
        return __errorArray(ResponseHelper::fromJSON($json)->message);
    }
    $host = Host::fromJSON($json);
    if (!empty($params['currentipaddress'])) {
        $host->removeIP($params['currentipaddress'], CommonFunctions::detectIPType($params['currentipaddress']));
    }
    if (!empty($params['newipaddress'])) {
        $host->addIP($params['newipaddress'], CommonFunctions::detectIPType($params['newipaddress']));
    }
    $json = STRegistry::Hosts()->update($host);
    if (!ResponseHelper::isSuccess($json)) {
        return __errorArray(ResponseHelper::fromJSON($json)->message);
    }
    return 'success';
}
开发者ID:digideskio,项目名称:whmcs-stregistry-module,代码行数:30,代码来源:stregistry.php

示例2: getRequestDataForUpdate

 private function getRequestDataForUpdate(Host $host)
 {
     $data = array('add' => array(), 'rem' => array());
     $json = STRegistry::Hosts()->query($host->getName());
     $currentHost = Host::fromJSON($json);
     foreach (array_merge($host->getIPv4(), $host->getIPv6()) as $id => $ip) {
         if (!in_array($ip, array_merge($currentHost->getIPv4(), $currentHost->getIPv6()))) {
             if (!isset($data['add']['addr'])) {
                 $data['add']['addr'] = array();
             }
             $data['add']['addr'][] = array($id => array('version' => CommonFunctions::detectIPType($ip), 'address' => $ip));
         }
     }
     foreach (array_merge($currentHost->getIPv4(), $currentHost->getIPv6()) as $id => $ip) {
         if (!in_array($ip, array_merge($host->getIPv4(), $host->getIPv6()))) {
             if (!isset($data['rem']['addr'])) {
                 $data['rem']['addr'] = array();
             }
             $data['rem']['addr'][] = array($id => array('version' => CommonFunctions::detectIPType($ip), 'address' => $ip));
         }
     }
     foreach ($host->getStatuses() as $status) {
         if (!in_array($status, $currentHost->getStatuses())) {
             if (!isset($data['add']['status'])) {
                 $data['add']['status'] = array();
             }
             $data['add']['status'][] = $status;
         }
     }
     foreach ($currentHost->getStatuses() as $status) {
         if (!in_array($status, $host->getStatuses())) {
             if (!isset($data['rem']['status'])) {
                 $data['rem']['status'] = array();
             }
             $data['rem']['status'][] = $status;
         }
     }
     return $data;
 }
开发者ID:digideskio,项目名称:whmcs-stregistry-module,代码行数:39,代码来源:Hosts.php


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