|
@@ -27,9 +27,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
class ProfilerListener
|
|
|
{
|
|
|
protected $container;
|
|
|
- protected $exception;
|
|
|
- protected $onlyException;
|
|
|
protected $matcher;
|
|
|
+ protected $onlyException;
|
|
|
+ protected $onlyMasterRequests;
|
|
|
+ protected $exception;
|
|
|
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -37,12 +38,14 @@ class ProfilerListener
|
|
|
* @param ContainerInterface $container A ContainerInterface instance
|
|
|
* @param RequestMatcherInterface $matcher A RequestMatcher instance
|
|
|
* @param Boolean $onlyException true if the profiler only collects data when an exception occurs, false otherwise
|
|
|
+ * @param Boolean $onlyMaster true if the profiler only collects data when the request is a master request, false otherwise
|
|
|
*/
|
|
|
- public function __construct(ContainerInterface $container, RequestMatcherInterface $matcher = null, $onlyException = false)
|
|
|
+ public function __construct(ContainerInterface $container, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false)
|
|
|
{
|
|
|
$this->container = $container;
|
|
|
$this->matcher = $matcher;
|
|
|
- $this->onlyException = $onlyException;
|
|
|
+ $this->onlyException = (Boolean) $onlyException;
|
|
|
+ $this->onlyMasterRequests = (Boolean) $onlyMasterRequests;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -81,6 +84,10 @@ class ProfilerListener
|
|
|
{
|
|
|
$response = $event->getResponse();
|
|
|
|
|
|
+ if ($this->onlyMasterRequests && HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
|
|
|
return $response;
|
|
|
}
|