コード例 #1
0
ファイル: Table.php プロジェクト: yao-dev/blog-mvc.github.io
 /**
  * Calls a finder method directly and applies it to the passed query,
  * if no query is passed a new one will be created and returned
  *
  * @param string $type name of the finder to be called
  * @param \Cake\ORM\Query $query The query object to apply the finder options to
  * @param array $options List of options to pass to the finder
  * @return \Cake\ORM\Query
  * @throws \BadMethodCallException
  */
 public function callFinder($type, Query $query, array $options = [])
 {
     $query->applyOptions($options);
     $options = $query->getOptions();
     $finder = 'find' . $type;
     if (method_exists($this, $finder)) {
         return $this->{$finder}($query, $options);
     }
     if ($this->_behaviors && $this->_behaviors->hasFinder($type)) {
         return $this->_behaviors->callFinder($type, [$query, $options]);
     }
     throw new \BadMethodCallException(sprintf('Unknown finder method "%s"', $type));
 }