Added the Containable behavior back into the AppModel, since it's obviously getting used in every controller.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@91 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-10 21:09:23 +00:00
parent 8d062ab92e
commit 18b928411b
9 changed files with 67 additions and 76 deletions

View File

@@ -33,7 +33,6 @@ class LedgerEntriesController extends AppController {
}
// Get the LedgerEntry and related fields
$this->LedgerEntry->Behaviors->attach('Containable');
$entry = $this->LedgerEntry->find
('first',
array('contain' => array('MonetarySource.id',
@@ -51,15 +50,15 @@ class LedgerEntriesController extends AppController {
'fields' => array('LedgerEntry.id',
'LedgerEntry.amount',
'LedgerEntry.comment'),
'conditions' => array('LedgerEntry.id' => $id),
));
$this->LedgerEntry->Behaviors->detach('Containable');
// Because 'DebitLedger' and 'CreditLedger' both relate to 'Account',
// CakePHP will not include them in the LedgerEntry->find (or so it
// seems). We'll have to break out each Account separately.
// Get the Account from DebitLedger
$this->LedgerEntry->DebitLedger->Account->Behaviors->attach('Containable');
$account = $this->LedgerEntry->DebitLedger->Account->find
('first',
array('contain' => true,
@@ -67,10 +66,8 @@ class LedgerEntriesController extends AppController {
'conditions' => array('Account.id' => $entry['DebitLedger']['account_id']),
));
$entry['DebitLedger'] = array_merge($entry['DebitLedger'], $account);
$this->LedgerEntry->DebitLedger->Account->Behaviors->detach('Containable');
// Get the Account from CreditLedger
$this->LedgerEntry->CreditLedger->Account->Behaviors->attach('Containable');
$account = $this->LedgerEntry->CreditLedger->Account->find
('first',
array('contain' => true,
@@ -78,7 +75,6 @@ class LedgerEntriesController extends AppController {
'conditions' => array('Account.id' => $entry['CreditLedger']['account_id']),
));
$entry['CreditLedger'] = array_merge($entry['CreditLedger'], $account);
$this->LedgerEntry->CreditLedger->Account->Behaviors->detach('Containable');
// Prepare to render.
$title = "Ledger Entry #{$entry['LedgerEntry']['id']}";