Skip to content

Commit

Permalink
Now plugin model can be specify in 'with' property of hasAndBelongsTo…
Browse files Browse the repository at this point in the history
…Many association.
  • Loading branch information
basuke authored and Yosuke Basuke Suzuki committed Sep 7, 2011
1 parent b14e821 commit 07b6523
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cake/libs/model/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@ protected function _deleteDependent($id, $cascade) {
*/
protected function _deleteLinks($id) {
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
$joinModel = $data['with'];
list($plugin, $joinModel) = pluginSplit($data['with']);
$records = $this->{$joinModel}->find('all', array(
'conditions' => array_merge(array($this->{$joinModel}->escapeField($data['foreignKey']) => $id)),
'fields' => $this->{$joinModel}->primaryKey,
Expand Down Expand Up @@ -3043,6 +3043,7 @@ public function getAssociated($type = null) {
*/
public function joinModel($assoc, $keys = array()) {
if (is_string($assoc)) {
list(, $assoc) = pluginSplit($assoc);
return array($assoc, array_keys($this->{$assoc}->schema()));
} elseif (is_array($assoc)) {
$with = key($assoc);
Expand Down

0 comments on commit 07b6523

Please sign in to comment.