Skip to content

Commit

Permalink
Revarting parts of the previous commit, was not a good idea
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Apr 10, 2014
1 parent bc4ee06 commit 6517284
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
30 changes: 18 additions & 12 deletions src/ORM/Association.php
Expand Up @@ -463,6 +463,24 @@ public function transformRow($row, $nestKey, $joined) {
return $row;
}

/**
* Returns a modified row after appending a property for this association
* with the default empty value according to whether the association was
* joined or fetched externally.
*
* @param array $row
* @param boolean $joined Whether or not the row is a result of a direct join
* with this association
* @return array
*/
public function defaultRowValue($row, $joined) {
$sourceAlias = $this->source()->alias();
if (isset($row[$sourceAlias])) {
$row[$sourceAlias][$this->property()] = null;
}
return $row;
}

/**
* Proxies the finding operation to the target table's find method
* and modifies the query accordingly based of this association
Expand Down Expand Up @@ -685,16 +703,4 @@ public abstract function isOwningSide(Table $side);
*/
public abstract function save(Entity $entity, $options = []);

/**
* Returns a modified row after appending a property for this association
* with the default empty value according to whether the association was
* joined or fetched externally.
*
* @param array $row
* @param boolean $joined Whether or not the row is a result of a direct join
* with this association
* @return array
*/
abstract public function defaultRowValue($row, $joined);

}
12 changes: 0 additions & 12 deletions src/ORM/Association/BelongsTo.php
Expand Up @@ -135,18 +135,6 @@ public function save(Entity $entity, $options = []) {
return $entity;
}

/**
* {@inheritdoc}
*
*/
public function defaultRowValue($row, $joined) {
$sourceAlias = $this->source()->alias();
if (isset($row[$sourceAlias])) {
$row[$sourceAlias][$this->property()] = null;
}
return $row;
}

/**
* Returns a single or multiple conditions to be appended to the generated join
* clause for getting the results on the target table.
Expand Down
12 changes: 0 additions & 12 deletions src/ORM/Association/HasOne.php
Expand Up @@ -130,18 +130,6 @@ public function save(Entity $entity, $options = []) {
return $entity;
}

/**
* {@inheritdoc}
*
*/
public function defaultRowValue($row, $joined) {
$sourceAlias = $this->source()->alias();
if (isset($row[$sourceAlias])) {
$row[$sourceAlias][$this->property()] = null;
}
return $row;
}

/**
* {@inheritdoc}
*
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -52,7 +52,7 @@ public function setUp() {
'\Cake\ORM\Association',
[
'_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide',
'save', 'eagerLoader', 'type', 'defaultRowValue'
'save', 'eagerLoader', 'type'
],
['Foo', $config]
);
Expand Down

0 comments on commit 6517284

Please sign in to comment.