Skip to content

Commit

Permalink
Fix deprecation notice regarding twig usage from controller. Should h…
Browse files Browse the repository at this point in the history
…elp for Symfony 6 compat. (#273)
  • Loading branch information
DamienHarper authored Sep 26, 2021
1 parent 2806bf8 commit 564d8f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Controller/ViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

class ViewerController extends AbstractController
{
private $environment;

public function __construct(\Twig\Environment $environment)
{
$this->environment = $environment;
}

/**
* @Route("/audit", name="dh_auditor_list_audits", methods={"GET"})
*/
Expand Down Expand Up @@ -90,4 +97,9 @@ public function showEntityHistoryAction(Request $request, Reader $reader, string
'paginator' => $pager,
]);
}

protected function renderView(string $view, array $parameters = []): string
{
return $this->environment->render($view, $parameters);
}
}
1 change: 1 addition & 0 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ services:

# Bundle related services
DH\AuditorBundle\Controller\ViewerController:
arguments: ['@twig']
calls:
- { method: setContainer, arguments: ['@service_container'] }
tags: ['controller.service_arguments']
Expand Down
2 changes: 2 additions & 0 deletions tests/DHAuditorBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Nyholm\BundleTest\BaseBundleTestCase;
use Nyholm\BundleTest\CompilerPass\PublicServicePass;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\HttpKernel\Kernel;

/**
Expand Down Expand Up @@ -44,6 +45,7 @@ public function testInitBundle(): void

$kernel->addBundle(DoctrineBundle::class);
$kernel->addBundle(SecurityBundle::class);
$kernel->addBundle(TwigBundle::class);

$this->bootKernel();

Expand Down
2 changes: 2 additions & 0 deletions tests/Twig/Extension/TwigExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Nyholm\BundleTest\BaseBundleTestCase;
use Nyholm\BundleTest\CompilerPass\PublicServicePass;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\HttpKernel\Kernel;

/**
Expand Down Expand Up @@ -36,6 +37,7 @@ protected function setUp(): void

$kernel->addBundle(DoctrineBundle::class);
$kernel->addBundle(SecurityBundle::class);
$kernel->addBundle(TwigBundle::class);

$this->bootKernel();

Expand Down

0 comments on commit 564d8f7

Please sign in to comment.