8000 Check if templating engine supports given view by fritzmg · Pull Request #40373 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Check if templating engine supports given view #40373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2021
Merged
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
Expand Up @@ -207,7 +207,7 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, string
*/
protected function renderView(string $view, array $parameters = []): string
{
if ($this->container->has('templating')) {
if ($this->container->has('templating') && $this->container->get('templating')->supports($view)) {
@trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED);

return $this->container->get('templating')->render($view, $parameters);
Expand All @@ -227,7 +227,7 @@ protected function renderView(string $view, array $parameters = []): string
*/
protected function render(string $view, array $parameters = [], Response $response = null): Response
{
if ($this->container->has('templating')) {
if ($this->container->has('templating') && $this->container->get('templating')->supports($view)) {
@trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED);

$content = $this->container->get('templating')->render($view, $parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ public function testRenderViewTemplating()
{
$templating = $this->createMock(EngineInterface::class);
$templating->expects($this->once())->method('render')->willReturn('bar');
$templating->expects($this->once())->method('supports')->willReturn(true);

$container = new Container();
$container->set('templating', $templating);
Expand All @@ -466,6 +467,7 @@ public function testRenderTemplating()
{
$templating = $this->createMock(EngineInterface::class);
$templating->expects($this->once())->method('render')->willReturn('bar');
$templating->expects($this->once())->method('supports')->willReturn(true);

$container = new Container();
$container->set('templating', $templating);
Expand Down
0