FOSElasticaBundle/Client.php

37 lines
1 KiB
PHP
Raw Normal View History

2011-10-04 17:01:38 +02:00
<?php
2011-10-04 17:26:14 +02:00
namespace FOS\ElasticaBundle;
2011-10-04 17:01:38 +02:00
use Elastica\Client as ElasticaClient;
2013-05-06 10:32:50 +02:00
use Elastica\Request;
use Elastica\Transport\Http;
use Elastica\Transport\Https;
2013-05-06 10:32:50 +02:00
2011-10-04 17:01:38 +02:00
/**
* @author Gordon Franke <info@nevalon.de>
*/
class Client extends ElasticaClient
2011-10-04 17:01:38 +02:00
{
public function request($path, $method = Request::GET, $data = array(), array $query = array())
2011-10-04 17:26:14 +02:00
{
$start = microtime(true);
2012-05-02 00:06:28 +02:00
$response = parent::request($path, $method, $data, $query);
if (null !== $this->_logger) {
$time = microtime(true) - $start;
$connection = $this->getLastRequest()->getConnection();
$transport = $connection->getTransportObject();
$full_host = null;
if ($transport instanceof Http || $transport instanceof Https) {
$full_host = $connection->getTransport().'://'.$connection->getHost().':'.$connection->getPort();
}
$this->_logger->logQuery($path, $method, $data, $time, $full_host);
2011-10-04 17:26:14 +02:00
}
2011-10-04 17:01:38 +02:00
return $response;
2011-10-04 17:01:38 +02:00
}
}