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


PHP StringHelper::isJson方法代码示例

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


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

示例1: executeAction

 public static function executeAction($instanceAction, $account, $instanceID)
 {
     $response = '';
     switch ($instanceAction) {
         case 'start':
             $response = self::getDriver($account)->startInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
             break;
         case 'stop':
             $response = self::getDriver($account)->stopInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
             break;
         case 'restart':
             $response = self::getDriver($account)->restartInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
             break;
         case 'terminate':
             $response = self::getDriver($account)->terminateInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
             break;
         case 'describeInstances':
             $response = self::getDriver($account)->describeInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
             break;
         case 'downloadKey':
             $responseJson = xDockerEngine::authenticate(array('username' => Auth::user()->username, 'password' => md5(Auth::user()->engine_key)));
             EngineLog::logIt(array('user_id' => Auth::id(), 'method' => 'authenticate-executeAction', 'return' => $responseJson));
             $obj = json_decode($responseJson);
             if (!empty($obj) && $obj->status == 'OK') {
                 $response = xDockerEngine::downloadKey(array('token' => $obj->token, 'cloudProvider' => $account->cloudProvider, 'instanceRegion' => $account->instanceRegion));
                 Log::info('downloadKey Json:' . $response);
                 if (StringHelper::isJson($response)) {
                     $response = json_decode($response, true);
                     $response['message'] = 'Key is returned in field key';
                 } else {
                     $response = array('status' => 'error', 'message' => 'Error occured while downloading keys');
                 }
             } else {
                 if (!empty($obj) && $obj->status == 'error') {
                     Log::error('Error occured while downloading key' . $obj->message);
                     $response = array('status' => $obj->status, 'message' => 'Unexpected error! Contact Support');
                 } else {
                     Log::error('Error occured while downloading key');
                     $response = array('status' => 'error', 'message' => 'Unexpected error! Contact Support');
                 }
             }
             break;
     }
     return $response;
 }
开发者ID:XDocker,项目名称:app,代码行数:45,代码来源:CloudProvider.php

示例2: getxDockerServiceStatus

 public static function getxDockerServiceStatus()
 {
     $responseJson = xDockerEngine::authenticate(array('username' => Auth::user()->username, 'password' => md5(Auth::user()->engine_key)));
     EngineLog::logIt(array('user_id' => Auth::id(), 'method' => 'getxDockerServiceStatus : authenticate', 'return' => $responseJson));
     $status = 'error';
     if (StringHelper::isJson($responseJson)) {
         $obj = json_decode($responseJson);
         if (!empty($obj) && $obj->status == 'OK') {
             $status = 'OK';
         }
     }
     return $status;
 }
开发者ID:XDocker,项目名称:app,代码行数:13,代码来源:xDockerEngine.php

示例3: getStatus

 public static function getStatus($json)
 {
     if (StringHelper::isJson($json)) {
         $obj = json_decode($json);
         return self::getLabel($obj->status);
     } else {
         return self::getLabel('error');
     }
 }
开发者ID:XDocker,项目名称:app,代码行数:9,代码来源:UIHelper.php


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