Permalink
Browse files

Moving more code around so tests can start passing

  • Loading branch information...
1 parent d07dae7 commit d24995392559122ff8de95584ece045ad035783f @lorenzo lorenzo committed Jan 29, 2014
Showing with 10 additions and 8 deletions.
  1. +9 −5 src/ORM/EagerLoader.php
  2. +1 −3 src/ORM/Query.php
View
@@ -14,6 +14,8 @@
*/
namespace Cake\ORM;
+use Cake\ORM\Table;
+use Cake\ORM\Query;
use Closure;
/**
@@ -148,15 +150,17 @@ protected function _reformatContain($associations, $original) {
/**
* Returns the fully normalized array of associations that should be eagerly
- * loaded. The normalized array will restructure the original one by sorting
- * all associations under one key and special options under another.
+ * loaded for a table. The normalized array will restructure the original array
+ * by sorting all associations under one key and special options under another.
*
* Additionally it will set an 'instance' key per association containing the
* association instance from the corresponding source table
*
+ * @param \Cake\ORM\Table $repository The table containing the association that
+ * will be normalized
* @return array
*/
- public function normalizedContainments() {
+ public function normalized(Table $repository) {
if ($this->_normalized !== null || empty($this->_containments)) {
return $this->_normalized;
}
@@ -168,7 +172,7 @@ public function normalizedContainments() {
break;
}
$contain[$table] = $this->_normalizeContain(
- $this->_table,
+ $repository,
$table,
$options
);
@@ -187,7 +191,7 @@ public function attachAssociations($query, $includeFields) {
return;
}
- $contain = $this->normalizedContainments();
+ $contain = $this->normalized($query->repository());
foreach ($contain as $relation => $meta) {
if ($meta['instance'] && !$meta['canBeJoined']) {
$this->_loadEagerly[$relation] = $meta;
View
@@ -309,12 +309,10 @@ public function eagerLoader(EagerLoader $instance = null) {
* @return \ArrayObject|Query
*/
public function contain($associations = null, $override = false) {
+ $result = $this->eagerLoader()->contain($associations, $override);
if ($associations !== null || $override) {
$this->_dirty();
- return $this;
}
-
- $result = $this->eagerLoader()->contain($associations, $override);
if ($associations === null) {
return $result;
}

0 comments on commit d249953

Please sign in to comment.