Bläddra i källkod

Merge pull request #1471 from EmmanuelVella/short-object-description

Check if route exists and is allowed for short object description
Thomas 12 år sedan
förälder
incheckning
a7ba7b063d

+ 1 - 3
Controller/HelperController.php

@@ -184,13 +184,11 @@ class HelperController
             }
         }
 
-        $url = $admin->generateUrl('edit', array('id' => $objectId));
-
         $htmlOutput = $this->twig->render($admin->getTemplate('short_object_description'),
             array(
+                'admin' => $admin,
                 'description' => $description,
                 'object' => $object,
-                'url' => $url
             )
         );
 

+ 6 - 2
Resources/views/Helper/short-object-description.html.twig

@@ -1,3 +1,7 @@
 <span class="inner-field-short-description">
-    <a href="{{ url }}" target="new">{{ description }}</a>
-</span>
+    {% if admin.hasRoute('edit') and admin.isGranted('EDIT') %}
+        <a href="{{ admin.generateObjectUrl('edit', object) }}" target="new">{{ description }}</a>
+    {% else %}
+        {{ description }}
+    {% endif %}
+</span>