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

add reorder option to list

Gordon Franke 13 éve
szülő
commit
5878a45af9
2 módosított fájl, 17 hozzáadás és 0 törlés
  1. 6 0
      Admin/FieldDescriptionCollection.php
  2. 11 0
      Datagrid/ListMapper.php

+ 6 - 0
Admin/FieldDescriptionCollection.php

@@ -91,4 +91,10 @@ class FieldDescriptionCollection implements \ArrayAccess, \Countable
     {
         return count($this->elements);
     }
+
+    public function reorder(array $keys)
+    {
+        array_unshift($keys, 'batch');
+        $this->elements = array_merge(array_flip($keys), $this->elements);
+    }
 }

+ 11 - 0
Datagrid/ListMapper.php

@@ -112,4 +112,15 @@ class ListMapper
 
         return $this;
     }
+
+    /**
+     * @param array $keys field names
+     * @return \Sonata\AdminBundle\Datagrid\ListMapper
+     */
+    public function reorder(array $keys)
+    {
+        $this->list->reorder($keys);
+
+        return $this;
+    }
 }