瀏覽代碼

Added configurable view for the short-object-description method of the helperController

Thanos Polymeneas 13 年之前
父節點
當前提交
859de9578a

+ 11 - 3
Controller/HelperController.php

@@ -178,9 +178,17 @@ class HelperController
             }
         }
 
-        $description = sprintf('<a href="%s" target="new">%s</a>', $admin->generateUrl('edit', array('id' => $objectId)), $description);
-
-        return new Response($description);
+        $url = $admin->generateUrl('edit', array('id' => $objectId));
+        
+        $htmlOutput = $this->twig->render($admin->getTemplate('short_object_description'),
+            array(
+                'description' => $description,
+                'object' => $object,
+                'url' => $url
+            )
+        );
+
+        return new Response($htmlOutput);
     }
 
     /**

+ 1 - 0
DependencyInjection/Configuration.php

@@ -135,6 +135,7 @@ class Configuration implements ConfigurationInterface
                         ->scalarNode('history')->defaultValue('SonataAdminBundle:CRUD:history.html.twig')->cannotBeEmpty()->end()
                         ->scalarNode('history_revision')->defaultValue('SonataAdminBundle:CRUD:history_revision.html.twig')->cannotBeEmpty()->end()
                         ->scalarNode('action')->defaultValue('SonataAdminBundle:CRUD:action.html.twig')->cannotBeEmpty()->end()
+                        ->scalarNode('short_object_description')->defaultValue('SonataAdminBundle:Helper:short-object-description.html.twig')->cannotBeEmpty()->end()
                     ->end()
                 ->end()
             ->end()

+ 1 - 0
Resources/views/Helper/short-object-description.html.twig

@@ -0,0 +1 @@
+<a href="{{url}}" target="new">{{description}}</a>