original_string: public function findChildren(Query $query, array $options)
      {
          $config = $this->getConfig();
          $options += ['for' => null, 'direct' => false];
          list($parent, $left, $right) = array_map(
              function ($field) {
                  return $this->_table->aliasField($field);
              },
              [$config['parent'], $config['left'], $config['right']]
          );
  
          list($for, $direct) = [$options['for'], $options['direct']];
  
          if (empty($for)) {
              throw new InvalidArgumentException("The 'for' key is required for find('children')");
          }
  
          if ($query->clause('order') === null) {
              $query->order([$left => 'ASC']);
          }
  
          if ($direct) {
              return $this->_scope($query)->where([$parent => $for]);
          }
  
          $node = $this->_getNode($for);
  
          return $this->_scope($query)
              ->where([
                  "{$right} <" => $node->get($config['right']),
                  "{$left} >" => $node->get($config['left']),
              ]);
      }
code: public function findChildren(Query $query, array $options)
      {
          $config = $this->getConfig();
          $options += ['for' => null, 'direct' => false];
          list($parent, $left, $right) = array_map(
              function ($field) {
                  return $this->_table->aliasField($field);
              },
              [$config['parent'], $config['left'], $config['right']]
          );
  
          list($for, $direct) = [$options['for'], $options['direct']];
  
          if (empty($for)) {
              throw new InvalidArgumentException("The 'for' key is required for find('children')");
          }
  
          if ($query->clause('order') === null) {
              $query->order([$left => 'ASC']);
          }
  
          if ($direct) {
              return $this->_scope($query)->where([$parent => $for]);
          }
  
          $node = $this->_getNode($for);
  
          return $this->_scope($query)
              ->where([
                  "{$right} <" => $node->get($config['right']),
                  "{$left} >" => $node->get($config['left']),
              ]);
      }
code_tokens: public function findChildren ( Query $ query , array $ options ) { $ config = $ this -> getConfig ( ) ; $ options += [ 'for' => null , 'direct' => false ] ; list ( $ parent , $ left , $ right ) = array_map ( function ( $ field ) { return $ this -> _table -> aliasField ( $ field ) ; } , [ $ config [ 'parent' ] , $ config [ 'left' ] , $ config [ 'right' ] ] ) ; list ( $ for , $ direct ) = [ $ options [ 'for' ] , $ options [ 'direct' ] ] ; if ( empty ( $ for ) ) { throw new InvalidArgumentException ( "The 'for' key is required for find('children')" ) ; } if ( $ query -> clause ( 'order' ) === null ) { $ query -> order ( [ $ left => 'ASC' ] ) ; } if ( $ direct ) { return $ this -> _scope ( $ query ) -> where ( [ $ parent => $ for ] ) ; } $ node = $ this -> _getNode ( $ for ) ; return $ this -> _scope ( $ query ) -> where ( [ "{$right} <" => $ node -> get ( $ config [ 'right' ] ) , "{$left} >" => $ node -> get ( $ config [ 'left' ] ) , ] ) ; }
docstring: Get the children nodes of the current model
  
  Available options are:
  
  - for: The id of the record to read.
  - direct: Boolean, whether to return only the direct (true), or all (false) children,
  defaults to false (all children).
  
  If the direct option is set to true, only the direct children are returned (based upon the parent_id field)
  
  @param \Cake\ORM\Query $query Query.
  @param array $options Array of options as described above
  @return \Cake\ORM\Query
  @throws \InvalidArgumentException When the 'for' key is not passed in $options
docstring_tokens: Get the children nodes of the current model