From 0f1ec7d003251769f5f731967983eb58559a7f39 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 9 Oct 2016 21:49:31 +0200 Subject: [PATCH] Removed double method. --- app/Support/Twig/Journal.php | 66 -------------------------------- app/Support/Twig/Transaction.php | 8 ++-- 2 files changed, 4 insertions(+), 70 deletions(-) diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php index d49171e3e1..62f99d89a6 100644 --- a/app/Support/Twig/Journal.php +++ b/app/Support/Twig/Journal.php @@ -18,9 +18,7 @@ use Amount; use FireflyIII\Models\Account; use FireflyIII\Models\Budget as ModelBudget; use FireflyIII\Models\Category; -use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; -use FireflyIII\Models\TransactionType; use FireflyIII\Support\CacheProperties; use Twig_Extension; use Twig_SimpleFilter; @@ -184,8 +182,6 @@ class Journal extends Twig_Extension $this->formatBudgetPerspective(), $this->journalBudgets(), $this->journalCategories(), - $this->transactionBudgets(), - $this->transactionCategories(), ]; return $functions; @@ -316,68 +312,6 @@ class Journal extends Twig_Extension ); } - /** - * @return Twig_SimpleFunction - */ - public function transactionBudgets(): Twig_SimpleFunction - { - return new Twig_SimpleFunction( - 'transactionBudgets', function (Transaction $transaction): string { - $cache = new CacheProperties; - $cache->addProperty($transaction->id); - $cache->addProperty('transaction'); - $cache->addProperty('budget-string'); - if ($cache->has()) { - return $cache->get(); - } - - $budgets = []; - // get all budgets: - foreach ($transaction->budgets as $budget) { - $budgets[] = '' . e($budget->name) . ''; - } - $string = join(', ', array_unique($budgets)); - $cache->store($string); - - return $string; - - - } - ); - } - - /** - * @return Twig_SimpleFunction - */ - public function transactionCategories(): Twig_SimpleFunction - { - return new Twig_SimpleFunction( - 'transactionCategories', function (Transaction $transaction): string { - $cache = new CacheProperties; - $cache->addProperty($transaction->id); - $cache->addProperty('transaction'); - $cache->addProperty('category-string'); - if ($cache->has()) { - return $cache->get(); - } - - - $categories = []; - // get all budgets: - foreach ($transaction->categories as $category) { - $categories[] = '' . e($category->name) . ''; - } - - $string = join(', ', array_unique($categories)); - $cache->store($string); - - return $string; - - - } - ); - } - /** * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's 5. * diff --git a/app/Support/Twig/Transaction.php b/app/Support/Twig/Transaction.php index 1baebdfc7a..234fee5b5a 100644 --- a/app/Support/Twig/Transaction.php +++ b/app/Support/Twig/Transaction.php @@ -149,7 +149,7 @@ class Transaction extends Twig_Extension if ($budgets->count() > 0) { $str = []; foreach ($budgets as $budget) { - $str[] = sprintf('%s', route('budgets.show', $budget->id), $budget->name, $budget->name); + $str[] = sprintf('%s', route('budgets.show', [$budget->id]), $budget->name, $budget->name); } return join(', ', $str); @@ -176,7 +176,7 @@ class Transaction extends Twig_Extension if ($categories->count() > 0) { $str = []; foreach ($categories as $category) { - $str[] = sprintf('%s', route('categories.show', $category->id), $category->name, $category->name); + $str[] = sprintf('%s', route('categories.show', [$category->id]), $category->name, $category->name); } return join(', ', $str); @@ -219,7 +219,7 @@ class Transaction extends Twig_Extension return '(cash)'; } - return '' . e($name) . ''; + return '' . e($name) . ''; }, ['is_safe' => ['html']] ); @@ -257,7 +257,7 @@ class Transaction extends Twig_Extension return '(cash)'; } - return '' . e($name) . ''; + return '' . e($name) . ''; }, ['is_safe' => ['html']] );