RunConverter.php in XHProf 8
File
src/Routing/RunConverter.php
View source
<?php
namespace Drupal\xhprof\Routing;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Drupal\xhprof\ProfilerInterface;
use Symfony\Component\Routing\Route;
class RunConverter implements ParamConverterInterface {
private $profiler;
public function __construct(ProfilerInterface $profiler) {
$this->profiler = $profiler;
}
public function convert($value, $definition, $name, array $defaults) {
try {
return $this->profiler
->getRun($value);
} catch (\Exception $e) {
return NULL;
}
}
public function applies($definition, $name, Route $route) {
if (!empty($definition['type']) && $definition['type'] === 'xhprof:run_id') {
return TRUE;
}
return FALSE;
}
}