Preciso customizar a chamada da função de callback no método run() da classe Connection.php, localizada em laravel\frameword\src\Illuminate\Database\Connection.php
O problema é que ela se encontra na pasta vendor do projeto, o que significa que não é o melhor local para efetuar a alteração.
Alguém poderia me dar uma luz de como posso fazer isso? O projeto contém várias classes e inúmeras operações de consultas espalhadas dentro do projeto. E como agora precisamos alterar as chamadas para API, o melhor local para alterar é neste método [run()]. A linha comentada
// $result = $this->runQueryCallback($query, $bindings, $callback);
contém a chamada original do pacote. Minha alteração é para a função de chamada para API, que já devolve os dados similarmente ao "runQueryCallbck"
$result = execSqlApiFirebird($query);
Aqui é o método completo:
/**
* Run a SQL statement and log its execution context.
*
* @param string $query
* @param array $bindings
* @param \Closure $callback
* @return mixed
*
* @throws \Illuminate\Database\QueryException
*/
protected function run($query, $bindings, Closure $callback)
{
$this->reconnectIfMissingConnection();
$start = microtime(true);
// Here we will run this query. If an exception occurs we'll determine if it was
// caused by a connection that has been lost. If that is the cause, we'll try
// to re-establish connection and re-run the query with a fresh connection.
try {
$query = str_replace(array('?'), array('\'%s\''), $query);
$query = vsprintf($query, $bindings);
// dump($query);
// $result = $this->runQueryCallback($query, $bindings, $callback);
$result = execSqlApiFirebird($query);
// dd($result);
} catch (QueryException $e) {
$result = $this->handleQueryException(
$e, $query, $bindings, $callback
);
}
// Once we have run the query we will calculate the time that it took to run and
// then log the query, bindings, and execution time so we will report them on
// the event that the developer needs them. We'll log time in milliseconds.
$this->logQuery(
$query, $bindings, $this->getElapsedTime($start)
);
// dump($result);
return $result;
}