8000 [Templating] #9071 array param for EngineInterface::render() by jillro · Pull Request #10832 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Templating] #9071 array param for EngineInterface::render() #10832

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function testRender()
{
$engine = $this->getTwig();

$this->assertSame('foo', $engine->render(array('foo', 'index')));
$this->assertSame('foo', $engine->render('index'));
$this->assertSame('foo', $engine->render(new TemplateReference('index')));
}
Expand Down
9 changes: 6 additions & 3 deletions src/Symfony/Bridge/Twig/TwigEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ public function supports($name)
/**
* Loads the given template.
*
* @param string|TemplateReferenceInterface|\Twig_Template $name A template name or an instance of
* TemplateReferenceInterface or \Twig_Template
* @param string|TemplateReferenceInterface|\Twig_Template|array $name A template name or an instance of
* TemplateReferenceInterface or \Twig_Template or
* an array of thoses.
*
* @return \Twig_TemplateInterface A \Twig_TemplateInterface instance
*
Expand All @@ -123,7 +124,9 @@ protected function load($name)
}

try {
return $this->environment->loadTemplate((string) $name);
return $this->environment->resolveTemplate(
is_array($name) ? $name : (string) $name
);
} catch (\Twig_Error_Loader $e) {
throw new \InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public function redirect($url, $status = 302)
/**
* Returns a rendered view.
*
* @param string $view The view name
* @param array $parameters An array of parameters to pass to the view
* @param string|array $view The view name or an array of view names.
* @param array $parameters An array of parameters to pass to the view
*
* @return string The rendered view
*/
Expand All @@ -96,9 +96,9 @@ public function renderView($view, array $parameters = array())
/**
* Renders a view.
*
* @param string $view The view name
* @param array $parameters An array of parameters to pass to the view
* @param Response $response A response instance
* @param string|array $view The view name or an array of view names.
* @param array $parameters An array of parameters to pass to the view
* @param Response $response A response instance
*
* @return Response A Response instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface EngineInterface extends BaseEngineInterface
/**
* Renders a view and returns a Response.
*
* @param string $view The view name
* @param string|array $view The view name or an array of view names.
* @param array $parameters An array of parameters to pass to the view
* @param Response $response A Response instance
*
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Templating/EngineInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ interface EngineInterface
/**
* Renders a template.
*
* @param string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance
* @param array $parameters An array of parameters to pass to the template
* @param string|TemplateReferenceInterface|array $name A template name or a TemplateReferenceInterface instance or an array of view names.
* @param array $parameters An array of parameters to pass to the template
*
* @return string The evaluated template as a string
*
Expand All @@ -62,7 +62,7 @@ public function exists($name);
/**
* Returns true if this class is able to render the given template.
*
* @param string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance
* @param string|TemplateReferenceInterface|array $name A template name or a TemplateReferenceInterface instance or an array of thoses.
*
* @return bool true if this class supports the given template, false otherwise
*
Expand Down
0