Skip to content

Commit

Permalink
Making Query json serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Aug 18, 2014
1 parent d35db70 commit 44ef9db
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ORM/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Cake\ORM\EagerLoader;
use Cake\ORM\ResultSet;
use Cake\ORM\Table;
use JsonSerializable;

/**
* Extends the base Query class to provide new methods related to association
Expand All @@ -28,7 +29,7 @@
* required.
*
*/
class Query extends DatabaseQuery {
class Query extends DatabaseQuery implements JsonSerializable {

use QueryTrait {
cache as private _cache;
Expand Down Expand Up @@ -744,4 +745,15 @@ public function __debugInfo() {
];
}

/**
* Exceutes the query and converts the result set into JSON.
*
* Part of JsonSerializable interface.
*
* @return \Cake\ORM\ResultSet the data to convert to json
*/
public function jsonSerialize() {
return $this->all();
}

}

0 comments on commit 44ef9db

Please sign in to comment.