Skip to content

Commit

Permalink
Pass the delete options into cascadeDelete calls.
Browse files Browse the repository at this point in the history
This allows the cascaded deletes to access the original options used
for the delete.
  • Loading branch information
markstory committed Nov 3, 2013
1 parent ff9f7c2 commit 1c38fc7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Cake/ORM/Association.php
Expand Up @@ -424,8 +424,9 @@ protected abstract function _joinCondition(array $options);
* required.
*
* @param Cake\ORM\Entity $entity The entity that started the cascaded delete.
* @param array $options The options for the original delete.
* @return boolean Success
*/
public abstract function cascadeDelete(Entity $entity);
public abstract function cascadeDelete(Entity $entity, $options = []);

}
3 changes: 2 additions & 1 deletion Cake/ORM/Association/BelongsTo.php
Expand Up @@ -59,9 +59,10 @@ public function foreignKey($key = null) {
* BelongsTo associations are never cleared in a cascading delete scenario.
*
* @param Cake\ORM\Entity $entity The entity that started the cascaded delete.
* @param array $options The options for the original delete.
* @return boolean Success.
*/
public function cascadeDelete(Entity $entity) {
public function cascadeDelete(Entity $entity, $options = []) {
return true;
}

Expand Down
3 changes: 2 additions & 1 deletion Cake/ORM/Association/BelongsToMany.php
Expand Up @@ -222,9 +222,10 @@ public function eagerLoader(array $options) {
* Clear out the data in the join/pivot table for a given entity.
*
* @param Cake\ORM\Entity $entity The entity that started the cascading delete.
* @param array $options The options for the original delete.
* @return boolean Success.
*/
public function cascadeDelete(Entity $entity) {
public function cascadeDelete(Entity $entity, $options = []) {
$foreignKey = $this->foreignKey();
$primaryKey = $this->source()->primaryKey();
$conditions = [
Expand Down
3 changes: 2 additions & 1 deletion Cake/ORM/Association/DependentDeleteTrait.php
Expand Up @@ -31,9 +31,10 @@ trait DependentDeleteTrait {
* This method does nothing if the association is not dependent.
*
* @param Cake\ORM\Entity $entity The entity that started the cascaded delete.
* @param array $options The options for the original delete.
* @return boolean Success.
*/
public function cascadeDelete(Entity $entity) {
public function cascadeDelete(Entity $entity, $options = []) {
if (!$this->dependent()) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Cake/ORM/Table.php
Expand Up @@ -989,7 +989,7 @@ protected function _processDelete($entity, $options) {
}

foreach ($this->_associations as $assoc) {
$assoc->cascadeDelete($entity);
$assoc->cascadeDelete($entity, $options);
}
return $success;
}
Expand Down

0 comments on commit 1c38fc7

Please sign in to comment.