Skip to content

Commit 3373dc3

Browse files
committed
Revert "feature #36184 [FrameworkBundle] Deprecate renderView() in favor of renderTemplate() (javiereguiluz)"
This reverts commit b494beb5dce0b00a27ffa8ef1e16fb1d46515680, reversing changes made to b9d41490fe9c1040b5d7eb50a14827bcf701885d.
1 parent 50d8470 commit 3373dc3

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

Controller/AbstractController.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -239,34 +239,22 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, string
239239

240240
/**
241241
* Returns a rendered view.
242-
*
243-
* @deprecated since Symfony 5.1, use renderTemplate() instead.
244242
*/
245243
protected function renderView(string $view, array $parameters = []): string
246-
{
247-
trigger_deprecation('symfony/framework-bundle', '5.1', 'The "%s" method is deprecated, use "renderTemplate()" instead.', __METHOD__);
248-
249-
return $this->renderTemplate($view, $parameters);
250-
}
251-
252-
/**
253-
* Returns a rendered template.
254-
*/
255-
protected function renderTemplate(string $templateName, array $parameters = []): string
256244
{
257245
if (!$this->container->has('twig')) {
258-
throw new \LogicException('You can not use the "renderTemplate()" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
246+
throw new \LogicException('You can not use the "renderView" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
259247
}
260248

261-
return $this->container->get('twig')->render($templateName, $parameters);
249+
return $this->container->get('twig')->render($view, $parameters);
262250
}
263251

264252
/**
265-
* Renders a template.
253+
* Renders a view.
266254
*/
267-
protected function render(string $templateName, array $parameters = [], Response $response = null): Response
255+
protected function render(string $view, array $parameters = [], Response $response = null): Response
268256
{
269-
$content = $this->renderTemplate($templateName, $parameters);
257+
$content = $this->renderView($view, $parameters);
270258

271259
if (null === $response) {
272260
$response = new Response();
@@ -278,18 +266,18 @@ protected function render(string $templateName, array $parameters = [], Response
278266
}
279267

280268
/**
281-
* Streams a template.
269+
* Streams a view.
282270
*/
283-
protected function stream(string $templatePath, array $parameters = [], StreamedResponse $response = null): StreamedResponse
271+
protected function stream(string $view, array $parameters = [], StreamedResponse $response = null): StreamedResponse
284272
{
285273
if (!$this->container->has('twig')) {
286274
throw new \LogicException('You can not use the "stream" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
287275
}
288276

289277
$twig = $this->container->get('twig');
290278

291-
$callback = function () use ($twig, $templatePath, $parameters) {
292-
$twig->display($templatePath, $parameters);
279+
$callback = function () use ($twig, $view, $parameters) {
280+
$twig->display($view, $parameters);
293281
};
294282

295283
if (null === $response) {

Tests/Controller/AbstractControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public function testdenyAccessUnlessGranted()
369369
$controller->denyAccessUnlessGranted('foo');
370370
}
371371

372-
public function testRenderTemplateTwig()
372+
public function testRenderViewTwig()
373373
{
374374
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock();
375375
$twig->expects($this->once())->method('render')->willReturn('bar');
@@ -380,7 +380,7 @@ public function testRenderTemplateTwig()
380380
$controller = $this->createController();
381381
$controller->setContainer($container);
382382

383-
$this->assertEquals('bar', $controller->renderTemplate('foo'));
383+
$this->assertEquals('bar', $controller->renderView('foo'));
384384
}
385385

386386
public function testRenderTwig()

0 commit comments

Comments
 (0)