Skip to content
Permalink
Browse files

Pass the delete options into cascadeDelete calls.

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 1c38fc7f33c4939f381588a779e0338e04e4f67c
@@ -424,8 +424,9 @@ public function transformRow($row) {
* 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 = []);
}
@@ -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;
}
@@ -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 = [
@@ -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;
}
@@ -989,7 +989,7 @@ protected function _processDelete($entity, $options) {
}
foreach ($this->_associations as $assoc) {
$assoc->cascadeDelete($entity);
$assoc->cascadeDelete($entity, $options);
}
return $success;
}

0 comments on commit 1c38fc7

Please sign in to comment.
You can’t perform that action at this time.