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


PHP Client::getConfigValue方法代码示例

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


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

示例1: _processResponse

 /**
  * @param \Elastica\Response $response
  *
  * @throws \Elastica\Exception\Bulk\ResponseException
  * @throws \Elastica\Exception\InvalidException
  *
  * @return \Elastica\Bulk\ResponseSet
  */
 protected function _processResponse(Response $response)
 {
     $responseData = $response->getData();
     $actions = $this->getActions();
     $bulkResponses = array();
     if (isset($responseData['items']) && is_array($responseData['items'])) {
         foreach ($responseData['items'] as $key => $item) {
             if (!isset($actions[$key])) {
                 throw new InvalidException('No response found for action #' . $key);
             }
             $action = $actions[$key];
             $opType = key($item);
             $bulkResponseData = reset($item);
             if ($action instanceof AbstractDocumentAction) {
                 $data = $action->getData();
                 if ($data instanceof Document && $data->isAutoPopulate() || $this->_client->getConfigValue(array('document', 'autoPopulate'), false)) {
                     if (!$data->hasId() && isset($bulkResponseData['_id'])) {
                         $data->setId($bulkResponseData['_id']);
                     }
                     if (isset($bulkResponseData['_version'])) {
                         $data->setVersion($bulkResponseData['_version']);
                     }
                 }
             }
             $bulkResponses[] = new BulkResponse($bulkResponseData, $action, $opType);
         }
     }
     $bulkResponseSet = new ResponseSet($response, $bulkResponses);
     if ($bulkResponseSet->hasError()) {
         throw new BulkResponseException($bulkResponseSet);
     }
     return $bulkResponseSet;
 }
开发者ID:levijackson,项目名称:Elastica,代码行数:41,代码来源:Bulk.php

示例2: sendUdp

 /**
  * @param string $host
  * @param int $port
  * @throws \Elastica\Exception\Bulk\UdpException
  */
 public function sendUdp($host = null, $port = null)
 {
     if (null === $host) {
         $host = $this->_client->getConfigValue(array('udp', 'host'), self::UDP_DEFAULT_HOST);
     }
     if (null === $port) {
         $port = $this->_client->getConfigValue(array('udp', 'port'), self::UDP_DEFAULT_PORT);
     }
     $message = $this->toString();
     $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     $result = socket_sendto($socket, $message, strlen($message), 0, $host, $port);
     socket_close($socket);
     if (false === $result) {
         throw new UdpException('UDP request failed');
     }
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:21,代码来源:Bulk.php

示例3: testConfigValue

 public function testConfigValue()
 {
     $config = array('level1' => array('level2' => array('level3' => 'value3'), 'level21' => 'value21'), 'level11' => 'value11');
     $client = new Client($config);
     $this->assertNull($client->getConfigValue('level12'));
     $this->assertFalse($client->getConfigValue('level12', false));
     $this->assertEquals(10, $client->getConfigValue('level12', 10));
     $this->assertEquals('value11', $client->getConfigValue('level11'));
     $this->assertNotNull($client->getConfigValue('level11'));
     $this->assertNotEquals(false, $client->getConfigValue('level11', false));
     $this->assertNotEquals(10, $client->getConfigValue('level11', 10));
     $this->assertEquals('value3', $client->getConfigValue(array('level1', 'level2', 'level3')));
     $this->assertInternalType('array', $client->getConfigValue(array('level1', 'level2')));
 }
开发者ID:viz,项目名称:wordpress-fantastic-elasticsearch,代码行数:14,代码来源:ClientTest.php


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