Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor refactor of Model::_deleteLinks to improve readability.

  • Loading branch information...
commit 7cfb5aba8ddcba05fe9d55a3182efd5477d0905a 1 parent 2d81d25
@markstory markstory authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 cake/libs/model/model.php
View
9 cake/libs/model/model.php
@@ -1825,14 +1825,15 @@ function _deleteDependent($id, $cascade) {
*/
function _deleteLinks($id) {
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
- $records = $this->{$data['with']}->find('all', array(
- 'conditions' => array_merge(array($this->{$data['with']}->escapeField($data['foreignKey']) => $id)),
- 'fields' => $this->{$data['with']}->primaryKey,
+ $joinModel = $data['with'];
+ $records = $this->{$joinModel}->find('all', array(
+ 'conditions' => array_merge(array($this->{$joinModel}->escapeField($data['foreignKey']) => $id)),
+ 'fields' => $this->{$joinModel}->primaryKey,
'recursive' => -1
));
if (!empty($records)) {
foreach ($records as $record) {
- $this->{$data['with']}->delete($record[$this->{$data['with']}->alias][$this->{$data['with']}->primaryKey]);
+ $this->{$joinModel}->delete($record[$this->{$joinModel}->alias][$this->{$joinModel}->primaryKey]);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.