Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removing Table::find() overloading
  • Loading branch information
lorenzo committed Dec 21, 2013
1 parent db62855 commit c1c63d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
22 changes: 14 additions & 8 deletions Cake/ORM/Table.php
Expand Up @@ -670,17 +670,23 @@ 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|array $type the type of query to perform, if an array is passed,
* it will be interpreted as the `$options` parameter
* @param array $options
* @param string $type the type of query to perform
* @param array $options An array that will be passed to Query::applyOptions
* By default it allows the following keys:
* - fields
* - conditions
* - order
* - limit
* - offset
* - page
* - order
* - group
* - having
* - contain
* - join
* @return \Cake\ORM\Query
*/
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
21 changes: 0 additions & 21 deletions Cake/Test/TestCase/ORM/TableTest.php
Expand Up @@ -2962,27 +2962,6 @@ public function testSimplifiedFind() {
$table->find();
}

/**
* Tests that it is possible to pass the conditions as first argument in find
*
* @return void
*/
public function testFindFirstParamAsArray() {
$table = $this->getMock(
'\Cake\ORM\Table',
['callFinder'],
[[
'connection' => $this->connection,
'schema' => ['id' => ['type' => 'integer']]
]]
);

$query = (new \Cake\ORM\Query($this->connection, $table))->select(['id']);
$table->expects($this->once())->method('callFinder')
->with('all', $query, ['fields' => ['id']]);
$table->find(['fields' => ['id']]);
}

/**
* Test that get() will use the primary key for searching and return the first
* entity found
Expand Down

0 comments on commit c1c63d6

Please sign in to comment.