Skip to content

Commit

Permalink
Register Twig bundle
Browse files Browse the repository at this point in the history
Twig Bundle is already required here. There's no reason not to register it automatically.
  • Loading branch information
simPod committed Mar 3, 2021
1 parent 31aeab2 commit 5b233a7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DependencyInjection/TracyBlueScreenExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class TracyBlueScreenExtension extends ConfigurableExtension implements Pr
public const CONTAINER_PARAMETER_CONSOLE_LISTENER_PRIORITY = 'cdn77.tracy_blue_screen.console.listener_priority';
public const CONTAINER_PARAMETER_CONSOLE_LOG_DIRECTORY = 'cdn77.tracy_blue_screen.console.log_directory';
public const CONTAINER_PARAMETER_CONTROLLER_LISTENER_PRIORITY = 'cdn77.tracy_blue_screen.controller.listener_priority';
private const TWIG_BUNDLE_ALIAS = 'twig';
public const TWIG_BUNDLE_ALIAS = 'twig';
private const TWIG_TEMPLATES_NAMESPACE = 'Twig';

public function prepend(ContainerBuilder $container) : void
Expand Down
8 changes: 8 additions & 0 deletions src/TracyBlueScreenBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@

namespace Cdn77\TracyBlueScreenBundle;

use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

final class TracyBlueScreenBundle extends Bundle
{
public function build(ContainerBuilder $container) : void
{
parent::build($container);

$container->registerExtension(new TwigExtension());
}
}
21 changes: 21 additions & 0 deletions tests/Cdn77/TracyBlueScreenBundle/TracyBlueScreenBundleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Cdn77\TracyBlueScreenBundle;

use Cdn77\TracyBlueScreenBundle\DependencyInjection\TracyBlueScreenExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class TracyBlueScreenBundleTest extends TestCase
{
public function testRegistersTwig() : void
{
$containerBuilder = new ContainerBuilder();
$bundle = new TracyBlueScreenBundle();
$bundle->build($containerBuilder);

self::assertTrue($containerBuilder->hasExtension(TracyBlueScreenExtension::TWIG_BUNDLE_ALIAS));
}
}

0 comments on commit 5b233a7

Please sign in to comment.