-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix link format handling with disabled templating
- Loading branch information
Showing
3 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/Symfony/Bundle/DebugBundle/DependencyInjection/Compiler/DumpDataCollectorPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?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\DebugBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* Registers the file link format for the {@link DumpDataCollector}. | ||
* | ||
* @author Christian Flothmann <christian.flothmann@xabbuh.de> | ||
*/ | ||
class DumpDataCollectorPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasDefinition('data_collector.dump')) { | ||
return; | ||
} | ||
|
||
$definition = $container->getDefinition('data_collector.dump'); | ||
|
||
if ($container->hasParameter('templating.helper.code.file_link_format')) { | ||
$definition->replaceArgument(1, $container->getParameter('templating.helper.code.file_link_format')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...mfony/Bundle/DebugBundle/Tests/DependencyInjection/Compiler/DumpDataCollectorPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?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\DebugBundle\Tests\DependencyInjection\Compiler; | ||
|
||
use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\DumpDataCollectorPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
class DumpDataCollectorPassTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testProcessWithFileLinkFormatParameter() | ||
{ | ||
$container = new ContainerBuilder(); | ||
$container->addCompilerPass(new DumpDataCollectorPass()); | ||
$container->setParameter('templating.helper.code.file_link_format', 'file-link-format'); | ||
|
||
$definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null)); | ||
$container->setDefinition('data_collector.dump', $definition); | ||
|
||
$container->compile(); | ||
|
||
$this->assertSame('file-link-format', $definition->getArgument(1)); | ||
} | ||
|
||
public function testProcessWithoutFileLinkFormatParameter() | ||
{ | ||
$container = new ContainerBuilder(); | ||
$container->addCompilerPass(new DumpDataCollectorPass()); | ||
|
||
$definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null)); | ||
$container->setDefinition('data_collector.dump', $definition); | ||
|
||
$container->compile(); | ||
|
||
$this->assertNull($definition->getArgument(1)); | ||
} | ||
} |