本文整理汇总了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;
}
示例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');
}
}
示例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')));
}