mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
fixed BC break on Environment::resolveTemplate()
This commit is contained in:
@@ -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
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user