Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* @author Christian Flothmann <christian.flothmann@sensiolabs.de>
*/
class RemoveInvalidDefinitionsPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->has('twig')) {
$container->removeDefinition('web_profiler.controller.exception');
$container->removeDefinition('web_profiler.controller.profiler');
$container->removeDefinition('web_profiler.controller.router');
$container->removeDefinition('web_profiler.debug_toolbar');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing all these makes the bundle useless, as the only goal of the bundle is to provide the UI to access the profiler data.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but at least clearing the cache does not fail now. I don't care which solution we choose, but anything is better DX-wise than the current behaviour.

}
}
}
6 changes: 6 additions & 0 deletions src/Symfony/Bundle/WebProfilerBundle/WebProfilerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\WebProfilerBundle;

use Symfony\Bundle\WebProfilerBundle\DependencyInjection\Compiler\RemoveInvalidDefinitionsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
Expand All @@ -20,4 +22,8 @@
*/
class WebProfilerBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new RemoveInvalidDefinitionsPass());
}
}