Skip to content

Commit

Permalink
Making the type in Table::find() optional
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Dec 20, 2013
1 parent 6f012c8 commit 956f4cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cake/ORM/Association.php
Expand Up @@ -438,7 +438,7 @@ public function type() {
* @see \Cake\ORM\Table::find()
* @return \Cake\ORM\Query
*/
public function find($type, $options = []) {
public function find($type = 'all', $options = []) {
return $this->target()
->find($type, $options)
->where($this->conditions());
Expand Down
10 changes: 8 additions & 2 deletions Cake/ORM/Table.php
Expand Up @@ -669,11 +669,17 @@ public function belongsToMany($associated, array $options = []) {
* Each find() will trigger a `Model.beforeFind` event for all attached
* listeners. Any listener can set a valid result set using $query
*
* @param string $type the type of query to perform
* @param string|array $type the type of query to perform, if an array is passed,
* it will be interpreted as the `$options` parameter
* @param array $options
* @return \Cake\ORM\Query
*/
public function find($type, $options = []) {
public function find($type = 'all', $options = []) {
if (!is_string($type)) {
$options = $type;
$type = 'all';
}

$query = $this->_buildQuery();
$query->select()->applyOptions($options);
return $this->callFinder($type, $query, $options);
Expand Down

0 comments on commit 956f4cc

Please sign in to comment.