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


PHP Google_Client::getClassConfig方法代码示例

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


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

示例1: __construct

 public function __construct(Google_Client $client)
 {
     if (!function_exists('memcache_connect') && !class_exists("Memcached")) {
         $error = "Memcache functions not available";
         $client->getLogger()->error($error);
         //throw new Google_Cache_Exception($error);
         echo json_encode(array('status' => FALSE, 'response-code' => 400, 'response' => $error, 'message' => $error, 'map' => ''));
         die;
     }
     $this->client = $client;
     if ($client->isAppEngine()) {
         // No credentials needed for GAE.
         $this->mc = new Memcached();
         $this->connection = true;
     } else {
         $this->host = $client->getClassConfig($this, 'host');
         $this->port = $client->getClassConfig($this, 'port');
         if (empty($this->host) || empty($this->port) && (string) $this->port != "0") {
             $error = "You need to supply a valid memcache host and port";
             $client->getLogger()->error($error);
             //throw new Google_Cache_Exception($error);
             echo json_encode(array('status' => FALSE, 'response-code' => 400, 'response' => $error, 'message' => $error, 'map' => ''));
             die;
         }
     }
 }
开发者ID:lo-lk-org,项目名称:LO_LK_V1,代码行数:26,代码来源:Memcache.php

示例2: nextChunk

 /**
  * Send the next part of the file to upload.
  * @param [$chunk] the next set of bytes to send. If false will used $data passed
  * at construct time.
  */
 public function nextChunk($chunk = false)
 {
     if (false == $this->resumeUri) {
         $this->resumeUri = $this->getResumeUri();
     }
     if (false == $chunk) {
         $chunk = substr($this->data, $this->progress, $this->chunkSize);
     }
     $lastBytePos = $this->progress + strlen($chunk) - 1;
     $headers = array('content-range' => "bytes {$this->progress}-{$lastBytePos}/{$this->size}", 'content-type' => $this->request->getRequestHeader('content-type'), 'content-length' => $this->chunkSize, 'expect' => '');
     $httpRequest = new Google_Http_Request($this->resumeUri, 'PUT', $headers, $chunk);
     if ($this->client->getClassConfig("Google_Http_Request", "enable_gzip_for_uploads")) {
         $httpRequest->enableGzip();
     } else {
         $httpRequest->disableGzip();
     }
     $response = $this->client->getIo()->makeRequest($httpRequest);
     $response->setExpectedClass($this->request->getExpectedClass());
     $code = $response->getResponseHttpCode();
     $this->httpResultCode = $code;
     if (308 == $code) {
         // Track the amount uploaded.
         $range = explode('-', $response->getResponseHeader('range'));
         $this->progress = $range[1] + 1;
         // Allow for changing upload URLs.
         $location = $response->getResponseHeader('location');
         if ($location) {
             $this->resumeUri = $location;
         }
         // No problems, but upload not complete.
         return false;
     } else {
         return Google_Http_REST::decodeHttpResponse($response);
     }
 }
开发者ID:omodev,项目名称:hooks,代码行数:40,代码来源:MediaFileUpload.php

示例3: makePutRequest

 /**
  * Sends a PUT-Request to google drive and parses the response,
  * setting the appropiate variables from the response()
  *
  * @param Google_Http_Request $httpRequest the Reuqest which will be send
  *
  * @return false|mixed false when the upload is unfinished or the decoded http response
  *
  */
 private function makePutRequest(Google_Http_Request $httpRequest)
 {
     if ($this->client->getClassConfig("Google_Http_Request", "enable_gzip_for_uploads")) {
         $httpRequest->enableGzip();
     } else {
         $httpRequest->disableGzip();
     }
     $response = $this->client->getIo()->makeRequest($httpRequest);
     $response->setExpectedClass($this->request->getExpectedClass());
     $code = $response->getResponseHttpCode();
     $this->httpResultCode = $code;
     if (308 == $code) {
         // Track the amount uploaded.
         $range = explode('-', $response->getResponseHeader('range'));
         $this->progress = $range[1] + 1;
         // Allow for changing upload URLs.
         $location = $response->getResponseHeader('location');
         if ($location) {
             $this->resumeUri = $location;
         }
         // No problems, but upload not complete.
         return false;
     } else {
         return Google_Http_REST::decodeHttpResponse($response, $this->client);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:35,代码来源:MediaFileUpload.php

示例4: __construct

 public function __construct(Google_Client $client)
 {
     if (!function_exists('memcache_connect') && !class_exists("Memcached")) {
         throw new Google_Cache_Exception("Memcache functions not available");
     }
     if ($client->isAppEngine()) {
         // No credentials needed for GAE.
         $this->mc = new Memcached();
         $this->connection = true;
     } else {
         $this->host = $client->getClassConfig($this, 'host');
         $this->port = $client->getClassConfig($this, 'port');
         if (empty($this->host) || empty($this->port) && (string) $this->port != "0") {
             throw new Google_Cache_Exception("You need to supply a valid memcache host and port");
         }
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:17,代码来源:Memcache.php

示例5: __construct

 public function __construct(Google_Client $client)
 {
     $this->client = $client;
     $timeout = $client->getClassConfig('Google_IO_Abstract', 'request_timeout_seconds');
     if ($timeout > 0) {
         $this->setTimeout($timeout);
     }
 }
开发者ID:AriannaCodes,项目名称:cs50-final,代码行数:8,代码来源:Abstract.php

示例6: __construct

 /**
  * Creates a new task runner with exponential backoff support.
  *
  * @param Google_Client $client The current API client
  * @param string $name The name of the current task (used for logging)
  * @param callable $action The task to run and possibly retry
  * @param array $arguments The task arguments
  * @throws Google_Task_Exception when misconfigured
  */
 public function __construct(Google_Client $client, $name, $action, array $arguments = array())
 {
     $config = (array) $client->getClassConfig('Google_Task_Runner');
     if (isset($config['initial_delay'])) {
         if ($config['initial_delay'] < 0) {
             throw new Google_Task_Exception('Task configuration `initial_delay` must not be negative.');
         }
         $this->delay = $config['initial_delay'];
     }
     if (isset($config['max_delay'])) {
         if ($config['max_delay'] <= 0) {
             throw new Google_Task_Exception('Task configuration `max_delay` must be greater than 0.');
         }
         $this->maxDelay = $config['max_delay'];
     }
     if (isset($config['factor'])) {
         if ($config['factor'] <= 0) {
             throw new Google_Task_Exception('Task configuration `factor` must be greater than 0.');
         }
         $this->factor = $config['factor'];
     }
     if (isset($config['jitter'])) {
         if ($config['jitter'] <= 0) {
             throw new Google_Task_Exception('Task configuration `jitter` must be greater than 0.');
         }
         $this->jitter = $config['jitter'];
     }
     if (isset($config['retries'])) {
         if ($config['retries'] < 0) {
             throw new Google_Task_Exception('Task configuration `retries` must not be negative.');
         }
         $this->maxAttempts += $config['retries'];
     }
     if (!is_callable($action)) {
         throw new Google_Task_Exception('Task argument `$action` must be a valid callable.');
     }
     $this->name = $name;
     $this->client = $client;
     $this->action = $action;
     $this->arguments = $arguments;
 }
开发者ID:hzhou9,项目名称:coupon_deal,代码行数:50,代码来源:Runner.php

示例7: __construct

 /**
  * @param Google_Client $client  The current Google client
  */
 public function __construct(Google_Client $client)
 {
     $this->setLevel($client->getClassConfig('Google_Logger_Abstract', 'level'));
     $format = $client->getClassConfig('Google_Logger_Abstract', 'log_format');
     $this->logFormat = $format ? $format : self::DEFAULT_LOG_FORMAT;
     $format = $client->getClassConfig('Google_Logger_Abstract', 'date_format');
     $this->dateFormat = $format ? $format : self::DEFAULT_DATE_FORMAT;
     $this->allowNewLines = (bool) $client->getClassConfig('Google_Logger_Abstract', 'allow_newlines');
 }
开发者ID:ksaltik,项目名称:YouTube-Analytics-Dashboard,代码行数:12,代码来源:Abstract.php

示例8: __construct

 public function __construct(Google_Client $client)
 {
     $this->path = $client->getClassConfig($this, 'directory');
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:4,代码来源:File.php

示例9: decodeHttpResponse

 /**
  * Decode an HTTP Response.
  * @static
  * @throws Google_Service_Exception
  * @param Google_Http_Request $response The http response to be decoded.
  * @param Google_Client $client
  * @return mixed|null
  */
 public static function decodeHttpResponse($response, Google_Client $client = null)
 {
     $code = $response->getResponseHttpCode();
     $body = $response->getResponseBody();
     $decoded = null;
     if (intVal($code) >= 300) {
         $decoded = json_decode($body, true);
         $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
         if (isset($decoded['error']) && isset($decoded['error']['message']) && isset($decoded['error']['code'])) {
             // if we're getting a json encoded error definition, use that instead of the raw response
             // body for improved readability
             $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
         } else {
             $err .= ": ({$code}) {$body}";
         }
         $errors = null;
         // Specific check for APIs which don't return error details, such as Blogger.
         if (isset($decoded['error']) && isset($decoded['error']['errors'])) {
             $errors = $decoded['error']['errors'];
         }
         $map = null;
         if ($client) {
             $client->getLogger()->error($err, array('code' => $code, 'errors' => $errors));
             $map = $client->getClassConfig('Google_Service_Exception', 'retry_map');
         }
         throw new Google_Service_Exception($err, $code, null, $errors, $map);
     }
     // Only attempt to decode the response, if the response code wasn't (204) 'no content'
     if ($code != '204') {
         if ($response->getExpectedRaw()) {
             return $body;
         }
         $decoded = json_decode($body, true);
         if ($decoded === null || $decoded === "") {
             $error = "Invalid json in service response: {$body}";
             if ($client) {
                 $client->getLogger()->error($error);
             }
             throw new Google_Service_Exception($error);
         }
         if ($response->getExpectedClass()) {
             $class = $response->getExpectedClass();
             $decoded = new $class($decoded);
         }
     }
     return $decoded;
 }
开发者ID:poweronio,项目名称:mbsite,代码行数:55,代码来源:REST.php


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