Added a routine that will cache stuff that costs a lot of queries.

This commit is contained in:
James Cole
2014-11-25 22:04:50 +01:00
parent 6e19bc01f5
commit 114b27079e
5 changed files with 88 additions and 8 deletions

View File

@@ -106,6 +106,14 @@ class TransactionController extends BaseController
* Trigger creation of new piggy bank event
*/
Event::fire('transactionJournal.destroy', [$transactionJournal]); // new and used.
/*
* Since this event will also destroy both transactions, trigger on those as
* well because we might want to update some caches and what-not.
*/
/** @var Transaction $transaction */
foreach ($transactionJournal->transactions as $transaction) {
Event::fire('transaction.destroy', [$transaction]);
}
/** @var \FireflyIII\Database\TransactionJournal $repository */
$repository = App::make('FireflyIII\Database\TransactionJournal');
@@ -363,6 +371,13 @@ class TransactionController extends BaseController
$piggyID = intval(Input::get('piggybank_id'));
}
Event::fire('transactionJournal.store', [$journal, $piggyID]); // new and used.
/*
* Also trigger on both transactions.
*/
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
Event::fire('transaction.store', [$transaction]);
}
if ($data['post_submit_action'] == 'create_another') {
return Redirect::route('transactions.create', $what)->withInput();
@@ -406,6 +421,14 @@ class TransactionController extends BaseController
Session::flash('success', 'Transaction updated!');
Event::fire('transactionJournal.update', [$journal]); // new and used.
/*
* Also trigger on both transactions.
*/
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
Event::fire('transaction.update', [$transaction]);
}
if (Input::get('post_submit_action') == 'return_to_edit') {
return Redirect::route('transactions.edit', $journal->id)->withInput();
} else {