소스 검색

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

Thanos Polymeneas 13 년 전
부모
커밋
859de9578a
3개의 변경된 파일13개의 추가작업 그리고 3개의 파일을 삭제
  1. 11 3
      Controller/HelperController.php
  2. 1 0
      DependencyInjection/Configuration.php
  3. 1 0
      Resources/views/Helper/short-object-description.html.twig

+ 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>