mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-02 13:37:41 +00:00
changed Environment::resolveTemplate() to always return a TemplateWrapper
This commit is contained in:
+3
-13
@@ -490,7 +490,7 @@ class Environment
|
||||
*
|
||||
* @param string|TemplateWrapper|array $names A template or an array of templates to try consecutively
|
||||
*
|
||||
* @return TemplateWrapper|Template
|
||||
* @return TemplateWrapper
|
||||
*
|
||||
* @throws LoaderError When none of the templates can be found
|
||||
* @throws SyntaxError When an error occurred during compilation
|
||||
@@ -498,23 +498,13 @@ class Environment
|
||||
public function resolveTemplate($names)
|
||||
{
|
||||
if (!\is_array($names)) {
|
||||
$names = [$names];
|
||||
return $this->load($names);
|
||||
}
|
||||
|
||||
foreach ($names as $name) {
|
||||
if ($name instanceof Template) {
|
||||
return $name;
|
||||
}
|
||||
if ($name instanceof TemplateWrapper) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->loadTemplate($name);
|
||||
return $this->load($name);
|
||||
} catch (LoaderError $e) {
|
||||
if (1 === \count($names)) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user