Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removing method alias, there is no need o create it so early at this

point
  • Loading branch information...
commit 463e31045cc15ea10c551940d9318e2c380cd5b1 1 parent f2cd735
@lorenzo lorenzo authored
Showing with 31 additions and 44 deletions.
  1. +29 −42 src/Datasource/QueryTrait.php
  2. +2 −2 tests/TestCase/ORM/QueryTest.php
View
71 src/Datasource/QueryTrait.php
@@ -116,42 +116,6 @@ public function getIterator() {
}
/**
- * Get the result set for this query.
- *
- * Will return either the results set through setResult(), or execute this query
- * and return the ResultSetDecorator object ready for streaming of results.
- *
- * @return Cake\Datasource\ResultSetDecorator
- */
- public function getResults() {
- if (isset($this->_results)) {
- return $this->_results;
- }
-
- $table = $this->repository();
- $event = new Event('Model.beforeFind', $table, [$this, $this->_options, true]);
- $table->getEventManager()->dispatch($event);
-
- if (isset($this->_results)) {
- return $this->_results;
- }
-
- if ($this->_cache) {
- $results = $this->_cache->fetch($this);
- }
- if (!isset($results)) {
- $results = $this->_decorateResults(
- new ResultSet($this, $this->execute())
- );
- if ($this->_cache) {
- $this->_cache->store($this, $results);
- }
- }
- $this->_results = $results;
- return $this->_results;
- }
-
-/**
* Enable result caching for this query.
*
* If a query has caching enabled, it will do the following when executed:
@@ -200,17 +164,40 @@ public function cache($key, $config = 'default') {
/**
* Fetch the results for this query.
*
- * Compiles the SQL representation of this query and executes it using the
- * provided connection object. Returns a ResultSetDecorator iterator object.
+ * Will return either the results set through setResult(), or execute this query
+ * and return the ResultSetDecorator object ready for streaming of results.
*
* ResultSetDecorator is a travesable object that implements the methods found
* on Cake\Collection\Collection.
*
* @return Cake\ORM\ResultSetDecorator
- * @throws RuntimeException if this method is called on a non-select Query.
*/
public function all() {
- return $this->getResults();
+ if (isset($this->_results)) {
+ return $this->_results;
+ }
+
+ $table = $this->repository();
+ $event = new Event('Model.beforeFind', $table, [$this, $this->_options, true]);
+ $table->getEventManager()->dispatch($event);
+
+ if (isset($this->_results)) {
+ return $this->_results;
+ }
+
+ if ($this->_cache) {
+ $results = $this->_cache->fetch($this);
+ }
+ if (!isset($results)) {
+ $results = $this->_decorateResults(
+ new ResultSet($this, $this->execute())
+ );
+ if ($this->_cache) {
+ $this->_cache->store($this, $results);
+ }
+ }
+ $this->_results = $results;
+ return $this->_results;
}
/**
@@ -238,7 +225,7 @@ public function toArray() {
* @param callable $mapper
* @param callable $reducer
* @param boolean $overwrite
- * @return Cake\ORM\Query|array
+ * @return Cake\Datasource\QueryTrait|array
* @see Cake\Collection\Iterator\MapReduce for details on how to use emit data to the map reducer.
*/
public function mapReduce(callable $mapper = null, callable $reducer = null, $overwrite = false) {
@@ -289,7 +276,7 @@ public function mapReduce(callable $mapper = null, callable $reducer = null, $ov
*
* @param callable $formatter
* @param boolean|integer $mode
- * @return Cake\ORM\Query|array
+ * @return Cake\Datasource\QueryTrait|array
*/
public function formatResults(callable $formatter = null, $mode = self::APPEND) {
if ($mode === self::OVERWRITE) {
View
4 tests/TestCase/ORM/QueryTest.php
@@ -1375,13 +1375,13 @@ public function collectionMethodsProvider() {
*/
public function testCollectionProxy($method, $arg) {
$query = $this->getMock(
- '\Cake\ORM\Query', ['getResults'],
+ '\Cake\ORM\Query', ['all'],
[$this->connection, $this->table]
);
$query->select();
$resultSet = $this->getMock('\Cake\ORM\ResultSet', [], [$query, null]);
$query->expects($this->once())
- ->method('getResults')
+ ->method('all')
->will($this->returnValue($resultSet));
$resultSet->expects($this->once())
->method($method)
Please sign in to comment.
Something went wrong with that request. Please try again.