You are here

public function Profiler::enable in XHProf 8

Conditionally enable XHProf profiling.

Overrides ProfilerInterface::enable

File

src/Profiler.php, line 78

Class

Profiler
Provides profiler service.

Namespace

Drupal\xhprof

Code

public function enable() {
  $config = $this->configFactory
    ->get('xhprof.config');
  $flags = $config
    ->get('flags');
  $excludeIndirectFunctions = $config
    ->get('exclude_indirect_functions');
  $modifier = 0;
  $extensionOptions = $this->activeExtension
    ->getOptions();
  foreach ($flags as $key => $value) {
    if ($value !== '0') {
      $extensionFlag = $extensionOptions[$key];
      $modifier += @constant($extensionFlag);
    }
  }
  $options = [];
  if ($excludeIndirectFunctions) {
    $options = [
      'ignored_functions' => [
        'call_user_func',
        'call_user_func_array',
      ],
    ];
  }
  $this->activeExtension
    ->enable($modifier, $options);
  $this->enabled = TRUE;
}