FOSElasticaBundle/Client.php

42 lines
1.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 FOS\ElasticaBundle\Logger\ElasticaLogger;
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 and $this->_logger instanceof ElasticaLogger) {
$time = microtime(true) - $start;
$connection = $this->getLastRequest()->getConnection();
$connection_array = array(
'host' => $connection->getHost(),
'port' => $connection->getPort(),
'transport' => $connection->getTransport(),
'headers' => $connection->getConfig('headers'),
);
$this->_logger->logQuery($path, $method, $data, $time, $connection_array, $query);
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
}
public function getIndex($name)
{
return new DynamicIndex($this, $name);
}
2011-10-04 17:01:38 +02:00
}