Skip to content

Commit

Permalink
Reset Profiler initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Oct 5, 2017
1 parent 10c1691 commit 2e3be87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,9 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
}
}

if (!$config['collect']) {
$container->getDefinition('profiler')->addMethodCall('disable', array());
}
$container->getDefinition('profiler')->addTag('kernel.reset', array('method' => 'reset'));
$container->getDefinition('profiler')
->addArgument(!$config['collect'])
->addTag('kernel.reset', array('method' => 'reset'));
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/Symfony/Component/HttpKernel/Profiler/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class Profiler
*/
private $logger;

/**
* @var bool
*/
private $initiallyEnabled = true;

/**
* @var bool
*/
Expand All @@ -50,11 +55,13 @@ class Profiler
*
* @param ProfilerStorageInterface $storage A ProfilerStorageInterface instance
* @param LoggerInterface $logger A LoggerInterface instance
* @param bool $enable The initial enabled state
*/
public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null)
public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null, $enable = true)
{
$this->storage = $storage;
$this->logger = $logger;
$this->initiallyEnabled = $this->enabled = (bool) $enable;
}

/**
Expand Down Expand Up @@ -199,6 +206,7 @@ public function reset()

$collector->reset();
}
$this->enabled = $this->initiallyEnabled;
}

/**
Expand Down

0 comments on commit 2e3be87

Please sign in to comment.