original_string: public function findThreaded(Query $query, array $options)
      {
          $options += [
              'keyField' => $this->getPrimaryKey(),
              'parentField' => 'parent_id',
              'nestingKey' => 'children'
          ];
  
          if (isset($options['idField'])) {
              $options['keyField'] = $options['idField'];
              unset($options['idField']);
              deprecationWarning('Option "idField" is deprecated, use "keyField" instead.');
          }
  
          $options = $this->_setFieldMatchers($options, ['keyField', 'parentField']);
  
          return $query->formatResults(function ($results) use ($options) {
              /** @var \Cake\Collection\CollectionInterface $results */
              return $results->nest($options['keyField'], $options['parentField'], $options['nestingKey']);
          });
      }
code: public function findThreaded(Query $query, array $options)
      {
          $options += [
              'keyField' => $this->getPrimaryKey(),
              'parentField' => 'parent_id',
              'nestingKey' => 'children'
          ];
  
          if (isset($options['idField'])) {
              $options['keyField'] = $options['idField'];
              unset($options['idField']);
              deprecationWarning('Option "idField" is deprecated, use "keyField" instead.');
          }
  
          $options = $this->_setFieldMatchers($options, ['keyField', 'parentField']);
  
          return $query->formatResults(function ($results) use ($options) {
              /** @var \Cake\Collection\CollectionInterface $results */
              return $results->nest($options['keyField'], $options['parentField'], $options['nestingKey']);
          });
      }
code_tokens: public function findThreaded ( Query $ query , array $ options ) { $ options += [ 'keyField' => $ this -> getPrimaryKey ( ) , 'parentField' => 'parent_id' , 'nestingKey' => 'children' ] ; if ( isset ( $ options [ 'idField' ] ) ) { $ options [ 'keyField' ] = $ options [ 'idField' ] ; unset ( $ options [ 'idField' ] ) ; deprecationWarning ( 'Option "idField" is deprecated, use "keyField" instead.' ) ; } $ options = $ this -> _setFieldMatchers ( $ options , [ 'keyField' , 'parentField' ] ) ; return $ query -> formatResults ( function ( $ results ) use ( $ options ) { /** @var \Cake\Collection\CollectionInterface $results */ return $ results -> nest ( $ options [ 'keyField' ] , $ options [ 'parentField' ] , $ options [ 'nestingKey' ] ) ; } ) ; }
docstring: Results for this finder will be a nested array, and is appropriate if you want
  to use the parent_id field of your model data to build nested results.
  
  Values belonging to a parent row based on their parent_id value will be
  recursively nested inside the parent row values using the `children` property
  
  You can customize what fields are used for nesting results, by default the
  primary key and the `parent_id` fields are used. If you wish to change
  these defaults you need to provide the keys `keyField`, `parentField` or `nestingKey` in
  `$options`:
  
  ```
  $table->find('threaded', [
  'keyField' => 'id',
  'parentField' => 'ancestor_id'
  'nestingKey' => 'children'
  ]);
  ```
  
  @param \Cake\ORM\Query $query The query to find with
  @param array $options The options to find with
  @return \Cake\ORM\Query The query builder
docstring_tokens: Results for this finder will be a nested array and is appropriate if you want to use the parent_id field of your model data to build nested results .