From f25a797b336c1a5b2ee7b664185172b36ec1aee2 Mon Sep 17 00:00:00 2001 From: Ya LG Date: Fri, 6 Jan 2017 14:34:29 +0100 Subject: [PATCH] [TwigBundle] Attempted to call an undefined method named "getTemplateName" of class "Twig_Error_Runtime". #21176 [TwigBundle] Attempted to call an undefined method named "getTemplateName" of class "Twig_Error_Runtime". #21176 --- src/Symfony/Bundle/TwigBundle/TwigEngine.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index 76daad58a3188..45037cfbcc675 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -52,12 +52,14 @@ public function render($name, array $parameters = array()) if ($name instanceof TemplateReference) { try { // try to get the real name of the template where the error occurred - $name = $e->getTemplateName(); - $path = (string) $this->locator->locate($this->parser->parse($name)); - if (method_exists($e, 'setSourceContext')) { - $e->setSourceContext(new \Twig_Source('', $name, $path)); - } else { - $e->setTemplateName($path); + if(method_exists($e,"getTemplateName")) { + $name = $e->getTemplateName(); + $path = (string) $this->locator->locate($this->parser->parse($name)); + if (method_exists($e, 'setSourceContext')) { + $e->setSourceContext(new \Twig_Source('', $name, $path)); + } else { + $e->setTemplateName($path); + } } } catch (\Exception $e2) { }