fixed BC break on Environment::resolveTemplate()

This commit is contained in:
Fabien Potencier
2019-03-15 17:22:49 +01:00
parent a482da9fd0
commit b24d52565a
2 changed files with 14 additions and 3 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.38.3 (2019-XX-XX)
* fixed BC break on Environment::resolveTemplate()
* fixed the bundled Autoloader to also load namespaced classes
* 1.38.2 (2019-03-12)
+13 -3
View File
@@ -597,7 +597,7 @@ class Environment
*
* @param string|Template|\Twig\TemplateWrapper|array $names A template or an array of templates to try consecutively
*
* @return TemplateWrapper
* @return TemplateWrapper|Template
*
* @throws LoaderError When none of the templates can be found
* @throws SyntaxError When an error occurred during compilation
@@ -605,13 +605,23 @@ class Environment
public function resolveTemplate($names)
{
if (!\is_array($names)) {
return $this->load($names);
$names = [$names];
}
foreach ($names as $name) {
if ($name instanceof Template) {
return $name;
}
if ($name instanceof TemplateWrapper) {
return $name;
}
try {
return $this->load($name);
return $this->loadTemplate($name);
} catch (LoaderError $e) {
if (1 === \count($names)) {
throw $e;
}
}
}