Skip to content

Commit

Permalink
Merge pull request #25 from mojoLyon/bugfix/check-sf-datacollector-va…
Browse files Browse the repository at this point in the history
…r2str-method

Add method stringifyVariable to use method depending on sf version
  • Loading branch information
Oliboy50 committed Feb 16, 2018
2 parents 990e877 + fc3fd54 commit 5ded812
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function handleEvent(ElasticsearchEvent $event)
$query = array(
'method' => $event->getMethod(),
'uri' => $event->getUri(),
'headers' => $this->varToString($event->getHeaders()),
'headers' => $this->stringifyVariable($event->getHeaders()),
'status_code' => $event->getStatusCode(),
'duration' => $event->getDuration(),
'took' => $event->getTook(),
Expand Down Expand Up @@ -86,4 +86,23 @@ public function reset()
];
}

/**
* Converts a PHP variable to a string or
* Converts the variable into a serializable Data instance.
*
* The convert action depend on method available in the sf DataCollector class.
* In sf >= 4, the DataCollector::varToString() doesn't exists anymore
*
* @param mixed $var
*
* @return mixed
*/
protected function stringifyVariable($var)
{
if (method_exists($this, 'varToString')) {
return $this->varToString($var);
} else {
return $this->cloneVar($var);
}
}
}

0 comments on commit 5ded812

Please sign in to comment.