Pārlūkot izejas kodu

Add support for link_parameters to short-description-box

Thomas Rabaix 11 gadi atpakaļ
vecāks
revīzija
85212dacbb

+ 19 - 16
Controller/HelperController.php

@@ -162,9 +162,10 @@ class HelperController
      */
      */
     public function getShortObjectDescriptionAction(Request $request)
     public function getShortObjectDescriptionAction(Request $request)
     {
     {
-        $code     = $request->get('code');
-        $objectId = $request->get('objectId');
-        $uniqid   = $request->get('uniqid');
+        $code           = $request->get('code');
+        $objectId       = $request->get('objectId');
+        $uniqid         = $request->get('uniqid');
+        $linkParameters = $request->get('linkParameters', array());
 
 
         $admin = $this->pool->getInstance($code);
         $admin = $this->pool->getInstance($code);
 
 
@@ -191,9 +192,10 @@ class HelperController
             )));
             )));
         } elseif ('html' == $request->get('_format')) {
         } elseif ('html' == $request->get('_format')) {
             return new Response($this->twig->render($admin->getTemplate('short_object_description'), array(
             return new Response($this->twig->render($admin->getTemplate('short_object_description'), array(
-                'admin'       => $admin,
-                'description' => $admin->toString($object),
-                'object'      => $object,
+                'admin'           => $admin,
+                'description'     => $admin->toString($object),
+                'object'          => $object,
+                'link_parameters' => $linkParameters
             )));
             )));
         } else {
         } else {
             throw new \RuntimeException('Invalid format');
             throw new \RuntimeException('Invalid format');
@@ -201,18 +203,19 @@ class HelperController
     }
     }
 
 
     /**
     /**
-     * @param  \Symfony\Component\HttpFoundation\Request  $request
+     * @param  \Symfony\Component\HttpFoundation\Request $request
+     *
      * @return \Symfony\Component\HttpFoundation\Response
      * @return \Symfony\Component\HttpFoundation\Response
      */
      */
     public function setObjectFieldValueAction(Request $request)
     public function setObjectFieldValueAction(Request $request)
     {
     {
-        $field      = $request->get('field');
-        $code       = $request->get('code');
-        $objectId   = $request->get('objectId');
-        $value      = $request->get('value');
-        $context    = $request->get('context');
+        $field    = $request->get('field');
+        $code     = $request->get('code');
+        $objectId = $request->get('objectId');
+        $value    = $request->get('value');
+        $context  = $request->get('context');
 
 
-        $admin       = $this->pool->getInstance($code);
+        $admin = $this->pool->getInstance($code);
         $admin->setRequest($request);
         $admin->setRequest($request);
 
 
         // alter should be done by using a post method
         // alter should be done by using a post method
@@ -250,14 +253,14 @@ class HelperController
         }
         }
 
 
         $propertyAccessor = PropertyAccess::getPropertyAccessor();
         $propertyAccessor = PropertyAccess::getPropertyAccessor();
-        $propertyPath = new PropertyPath($field);
+        $propertyPath     = new PropertyPath($field);
 
 
         // If property path has more than 1 element, take the last object in order to validate it
         // If property path has more than 1 element, take the last object in order to validate it
         if ($propertyPath->getLength() > 1) {
         if ($propertyPath->getLength() > 1) {
             $object = $propertyAccessor->getValue($object, $propertyPath->getParent());
             $object = $propertyAccessor->getValue($object, $propertyPath->getParent());
 
 
-            $elements = $propertyPath->getElements();
-            $field = end($elements);
+            $elements     = $propertyPath->getElements();
+            $field        = end($elements);
             $propertyPath = new PropertyPath($field);
             $propertyPath = new PropertyPath($field);
         }
         }
 
 

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

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