original_string: public function findComments(Query $query, $options)
      {
          $tableAlias = Inflector::underscore($this->_table->alias());
  
          if (empty($options['for'])) {
              throw new \InvalidArgumentException("The 'for' key is required for find('children')");
          }
  
          $comments = $this->_table->Comments
              ->find('threaded')
              ->where(['table_alias' => $tableAlias, 'entity_id' => $options['for']])
              ->order($this->config('order'))
              ->all();
  
          return $comments;
      }
code: public function findComments(Query $query, $options)
      {
          $tableAlias = Inflector::underscore($this->_table->alias());
  
          if (empty($options['for'])) {
              throw new \InvalidArgumentException("The 'for' key is required for find('children')");
          }
  
          $comments = $this->_table->Comments
              ->find('threaded')
              ->where(['table_alias' => $tableAlias, 'entity_id' => $options['for']])
              ->order($this->config('order'))
              ->all();
  
          return $comments;
      }
code_tokens: public function findComments ( Query $ query , $ options ) { $ tableAlias = Inflector :: underscore ( $ this -> _table -> alias ( ) ) ; if ( empty ( $ options [ 'for' ] ) ) { throw new \ InvalidArgumentException ( "The 'for' key is required for find('children')" ) ; } $ comments = $ this -> _table -> Comments -> find ( 'threaded' ) -> where ( [ 'table_alias' => $ tableAlias , 'entity_id' => $ options [ 'for' ] ] ) -> order ( $ this -> config ( 'order' ) ) -> all ( ) ; return $ comments ; }
docstring: Get comments for the given entity.
  
  Allows you to get all comments even when this behavior was disabled
  using `unbindComments()`.
  
  ### Usage:
  
  // in your controller, gets comments for post which id equals 2
  $postComments = $this->Posts->find('comments', ['for' => 2]);
  
  @param \Cake\ORM\Query $query The query object
  @param array $options Additional options as an array
  @return \Cake\Datasource\ResultSetDecorator Comments collection
  @throws \InvalidArgumentException When the 'for' key is not passed in $options
docstring_tokens: Get comments for the given entity .