public function Profiler::canEnable in XHProf 8
Returns whether a profiling can be enabled for the current request.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request.
Return value
bool TRUE profiling can be enabled, FALSE otherwise.
Overrides ProfilerInterface::canEnable
File
- src/
Profiler.php, line 127
Class
- Profiler
- Provides profiler service.
Namespace
Drupal\xhprofCode
public function canEnable(Request $request) {
$config = $this->configFactory
->get('xhprof.config');
if ($this
->isLoaded() && $config
->get('enabled') && $this->requestMatcher
->matches($request)) {
$interval = $config
->get('interval');
if ($interval && mt_rand(1, $interval) % $interval != 0) {
return FALSE;
}
return TRUE;
}
return FALSE;
}