fixed the registration of the web profiler when the profiler is disabled
This commit is contained in:
parent
a11f9017aa
commit
88ebd62e1c
@ -210,6 +210,9 @@ class FrameworkExtension extends Extension
|
|||||||
private function registerProfilerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
private function registerProfilerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||||
{
|
{
|
||||||
if (!$this->isConfigEnabled($container, $config)) {
|
if (!$this->isConfigEnabled($container, $config)) {
|
||||||
|
// this is needed for the WebProfiler to work even if the profiler is disabled
|
||||||
|
$container->setParameter('data_collector.templates', array());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Controller;
|
|||||||
|
|
||||||
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
||||||
use Symfony\Component\HttpKernel\Debug\ExceptionHandler;
|
use Symfony\Component\HttpKernel\Debug\ExceptionHandler;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +27,7 @@ class ExceptionController
|
|||||||
protected $debug;
|
protected $debug;
|
||||||
protected $profiler;
|
protected $profiler;
|
||||||
|
|
||||||
public function __construct(Profiler $profiler, \Twig_Environment $twig, $debug)
|
public function __construct(Profiler $profiler = null, \Twig_Environment $twig, $debug)
|
||||||
{
|
{
|
||||||
$this->profiler = $profiler;
|
$this->profiler = $profiler;
|
||||||
$this->twig = $twig;
|
$this->twig = $twig;
|
||||||
@ -42,6 +43,10 @@ class ExceptionController
|
|||||||
*/
|
*/
|
||||||
public function showAction($token)
|
public function showAction($token)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
$exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException();
|
$exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException();
|
||||||
@ -76,6 +81,10 @@ class ExceptionController
|
|||||||
*/
|
*/
|
||||||
public function cssAction($token)
|
public function cssAction($token)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
$exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException();
|
$exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException();
|
||||||
|
@ -43,7 +43,7 @@ class ProfilerController
|
|||||||
* @param array $templates The templates
|
* @param array $templates The templates
|
||||||
* @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration)
|
* @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration)
|
||||||
*/
|
*/
|
||||||
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler, \Twig_Environment $twig, array $templates, $toolbarPosition = 'normal')
|
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, \Twig_Environment $twig, array $templates, $toolbarPosition = 'normal')
|
||||||
{
|
{
|
||||||
$this->generator = $generator;
|
$this->generator = $generator;
|
||||||
$this->profiler = $profiler;
|
$this->profiler = $profiler;
|
||||||
@ -59,6 +59,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function homeAction()
|
public function homeAction()
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
return new RedirectResponse($this->generator->generate('_profiler_search_results', array('token' => 'empty', 'limit' => 10)));
|
return new RedirectResponse($this->generator->generate('_profiler_search_results', array('token' => 'empty', 'limit' => 10)));
|
||||||
@ -76,6 +80,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function panelAction(Request $request, $token)
|
public function panelAction(Request $request, $token)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
$panel = $request->query->get('panel', 'request');
|
$panel = $request->query->get('panel', 'request');
|
||||||
@ -112,6 +120,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function exportAction($token)
|
public function exportAction($token)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
if (!$profile = $this->profiler->loadProfile($token)) {
|
if (!$profile = $this->profiler->loadProfile($token)) {
|
||||||
@ -131,6 +143,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function purgeAction()
|
public function purgeAction()
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
$this->profiler->purge();
|
$this->profiler->purge();
|
||||||
|
|
||||||
@ -146,6 +162,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function importAction(Request $request)
|
public function importAction(Request $request)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
$file = $request->files->get('file');
|
$file = $request->files->get('file');
|
||||||
@ -170,6 +190,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function infoAction($about)
|
public function infoAction($about)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
|
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
|
||||||
@ -187,6 +211,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function toolbarAction(Request $request, $token)
|
public function toolbarAction(Request $request, $token)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$session = $request->getSession();
|
$session = $request->getSession();
|
||||||
|
|
||||||
if (null !== $session && $session->getFlashBag() instanceof AutoExpireFlashBag) {
|
if (null !== $session && $session->getFlashBag() instanceof AutoExpireFlashBag) {
|
||||||
@ -234,6 +262,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function searchBarAction(Request $request)
|
public function searchBarAction(Request $request)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
if (null === $session = $request->getSession()) {
|
if (null === $session = $request->getSession()) {
|
||||||
@ -275,6 +307,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function searchResultsAction(Request $request, $token)
|
public function searchResultsAction(Request $request, $token)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
$profile = $this->profiler->loadProfile($token);
|
$profile = $this->profiler->loadProfile($token);
|
||||||
@ -309,6 +345,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function searchAction(Request $request)
|
public function searchAction(Request $request)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
$ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip'));
|
$ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip'));
|
||||||
@ -353,6 +393,10 @@ class ProfilerController
|
|||||||
*/
|
*/
|
||||||
public function phpinfoAction()
|
public function phpinfoAction()
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
@ -30,7 +30,7 @@ class RouterController
|
|||||||
private $matcher;
|
private $matcher;
|
||||||
private $routes;
|
private $routes;
|
||||||
|
|
||||||
public function __construct(Profiler $profiler, \Twig_Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null)
|
public function __construct(Profiler $profiler = null, \Twig_Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null)
|
||||||
{
|
{
|
||||||
$this->profiler = $profiler;
|
$this->profiler = $profiler;
|
||||||
$this->twig = $twig;
|
$this->twig = $twig;
|
||||||
@ -51,6 +51,10 @@ class RouterController
|
|||||||
*/
|
*/
|
||||||
public function panelAction($token)
|
public function panelAction($token)
|
||||||
{
|
{
|
||||||
|
if (null === $this->profiler) {
|
||||||
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
if (null === $this->matcher || null === $this->routes) {
|
if (null === $this->matcher || null === $this->routes) {
|
||||||
|
@ -39,10 +39,6 @@ class WebProfilerExtension extends Extension
|
|||||||
*/
|
*/
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
if (!$container->hasParameter('profiler.class')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$configuration = $this->getConfiguration($configs, $container);
|
$configuration = $this->getConfiguration($configs, $container);
|
||||||
$config = $this->processConfiguration($configuration, $configs);
|
$config = $this->processConfiguration($configuration, $configs);
|
||||||
|
|
||||||
|
@ -13,20 +13,20 @@
|
|||||||
<services>
|
<services>
|
||||||
<service id="web_profiler.controller.profiler" class="%web_profiler.controller.profiler.class%">
|
<service id="web_profiler.controller.profiler" class="%web_profiler.controller.profiler.class%">
|
||||||
<argument type="service" id="router" on-invalid="null" />
|
<argument type="service" id="router" on-invalid="null" />
|
||||||
<argument type="service" id="profiler" />
|
<argument type="service" id="profiler" on-invalid="null" />
|
||||||
<argument type="service" id="twig" />
|
<argument type="service" id="twig" />
|
||||||
<argument>%data_collector.templates%</argument>
|
<argument>%data_collector.templates%</argument>
|
||||||
<argument>%web_profiler.debug_toolbar.position%</argument>
|
<argument>%web_profiler.debug_toolbar.position%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="web_profiler.controller.router" class="%web_profiler.controller.router.class%">
|
<service id="web_profiler.controller.router" class="%web_profiler.controller.router.class%">
|
||||||
<argument type="service" id="profiler" />
|
<argument type="service" id="profiler" on-invalid="null" />
|
||||||
<argument type="service" id="twig" />
|
<argument type="service" id="twig" />
|
||||||
<argument type="service" id="router" on-invalid="null" />
|
<argument type="service" id="router" on-invalid="null" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="web_profiler.controller.exception" class="%web_profiler.controller.exception.class%">
|
<service id="web_profiler.controller.exception" class="%web_profiler.controller.exception.class%">
|
||||||
<argument type="service" id="profiler" />
|
<argument type="service" id="profiler" on-invalid="null" />
|
||||||
<argument type="service" id="twig" />
|
<argument type="service" id="twig" />
|
||||||
<argument>%kernel.debug%</argument>
|
<argument>%kernel.debug%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
Reference in New Issue
Block a user