Forráskód Böngészése

Avoid exception is the template is not defined

Thomas Rabaix 13 éve
szülő
commit
7ccb9f407d
1 módosított fájl, 3 hozzáadás és 1 törlés
  1. 3 1
      Twig/Extension/SonataAdminExtension.php

+ 3 - 1
Twig/Extension/SonataAdminExtension.php

@@ -72,8 +72,10 @@ class SonataAdminExtension extends \Twig_Extension
     protected function getTemplate(FieldDescriptionInterface $fieldDescription, $default)
     protected function getTemplate(FieldDescriptionInterface $fieldDescription, $default)
     {
     {
         // todo: find a better solution
         // todo: find a better solution
+        $templateName = $fieldDescription->getTemplate() ?: $default;
+
         try {
         try {
-            $template = $this->environment->loadTemplate($fieldDescription->getTemplate());
+            $template = $this->environment->loadTemplate($templateName);
         } catch(\Twig_Error_Loader $e) {
         } catch(\Twig_Error_Loader $e) {
             $template = $this->environment->loadTemplate($default);
             $template = $this->environment->loadTemplate($default);
         }
         }