Browse Source

Restore accidentally removed method.

mark_story 11 years ago
parent
commit
d420d46485
1 changed files with 27 additions and 0 deletions
  1. 27 0
      src/ORM/Behavior/TreeBehavior.php

+ 27 - 0
src/ORM/Behavior/TreeBehavior.php

@@ -444,6 +444,33 @@ class TreeBehavior extends Behavior
      *
      * ### Options
      *
+     * - keyPath: A dot separated path to fetch the field to use for the array key, or a closure to
+     *   return the key out of the provided row.
+     * - valuePath: A dot separated path to fetch the field to use for the array value, or a closure to
+     *   return the value out of the provided row.
+     * - spacer: A string to be used as prefix for denoting the depth in the tree for each item
+     *
+     * @param \Cake\ORM\Query $query Query.
+     * @param array $options Array of options as described above.
+     * @return \Cake\ORM\Query
+     */
+    public function findTreeList(Query $query, array $options)
+    {
+        $results = $this->_scope($query)
+            ->find('threaded', [
+                'parentField' => $this->config('parent'),
+                'order' => [$this->config('left') => 'ASC']
+            ]);
+        return $this->formatTreeList($results, $options);
+    }
+
+    /**
+     * Formats query as a flat list where the keys are the primary key for the table
+     * and the values are the display field for the table. Values are prefixed to visually
+     * indicate relative depth in the tree.
+     *
+     * ### Options
+     *
      * - keyPath: A dot separated path to the field that will be the result array key, or a closure to
      *   return the key from the provided row.
      * - valuePath: A dot separated path to the field that is the array's value, or a closure to