Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Moving the abstract method requirement for eagerLoader to Association
  • Loading branch information
lorenzo committed Mar 31, 2014
1 parent beef973 commit 872dca1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/ORM/Association.php
Expand Up @@ -576,6 +576,15 @@ protected function _bindNewAssociations($query, $surrogate, $options) {
$query->contain($newBinds);
}

/**
* Eager loads a list of records in the target table that are related to another
* set of records in the source table.
*
* @param array $options
* @return \Closure
*/
public abstract function eagerLoader(array $options);

/**
* Returns a single or multiple condition(s) to be appended to the generated join
* clause for getting the results on the target table. If false is returned then
Expand Down
10 changes: 10 additions & 0 deletions src/ORM/Association/BelongsTo.php
Expand Up @@ -90,6 +90,16 @@ public function isOwningSide(Table $side) {
return $side === $this->target();
}

/**
* Eager loads a list of records in the target table that are related to another
* set of records in the source table.
*
* @param array $options
* @return \Closure
*/
public function eagerLoader(array $options) {
}

/**
* Takes an entity from the source table and looks if there is a field
* matching the property name for this association. The found entity will be
Expand Down
9 changes: 0 additions & 9 deletions src/ORM/Association/ExternalAssociationTrait.php
Expand Up @@ -110,15 +110,6 @@ public function transformRow($row, $joined) {
return $row;
}

/**
* Eager loads a list of records in the target table that are related to another
* set of records in the source table.
*
* @param array $options
* @return \Closure
*/
public abstract function eagerLoader(array $options);

/**
* Returns a single or multiple conditions to be appended to the generated join
* clause for getting the results on the target table.
Expand Down
10 changes: 10 additions & 0 deletions src/ORM/Association/HasOne.php
Expand Up @@ -87,6 +87,16 @@ public function isOwningSide(Table $side) {
return $side === $this->source();
}

/**
* Eager loads a list of records in the target table that are related to another
* set of records in the source table.
*
* @param array $options
* @return \Closure
*/
public function eagerLoader(array $options) {
}

/**
* Takes an entity from the source table and looks if there is a field
* matching the property name for this association. The found entity will be
Expand Down
5 changes: 4 additions & 1 deletion tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -50,7 +50,10 @@ public function setUp() {
];
$this->association = $this->getMock(
'\Cake\ORM\Association',
['_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide', 'save'],
[
'_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide',
'save', 'eagerLoader'
],
['Foo', $config]
);
}
Expand Down

0 comments on commit 872dca1

Please sign in to comment.