소스 검색

add reorder option to list

Gordon Franke 13 년 전
부모
커밋
5878a45af9
2개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  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;
+    }
 }