Removed double method.

This commit is contained in:
James Cole 2016-10-09 21:49:31 +02:00
parent 7e038afece
commit 0f1ec7d003
2 changed files with 4 additions and 70 deletions

View File

@ -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[] = '<a href="' . route('budgets.show', [$budget->id]) . '" title="' . e($budget->name) . '">' . e($budget->name) . '</a>';
}
$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[] = '<a href="' . route('categories.show', [$category->id]) . '" title="' . e($category->name) . '">' . e($category->name) . '</a>';
}
$string = join(', ', array_unique($categories));
$cache->store($string);
return $string;
}
);
}
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's 5.
*

View File

@ -149,7 +149,7 @@ class Transaction extends Twig_Extension
if ($budgets->count() > 0) {
$str = [];
foreach ($budgets as $budget) {
$str[] = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', $budget->id), $budget->name, $budget->name);
$str[] = sprintf('<a href="%s" title="%s">%s</a>', 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('<a href="%s" title="%s">%s</a>', route('categories.show', $category->id), $category->name, $category->name);
$str[] = sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$category->id]), $category->name, $category->name);
}
return join(', ', $str);
@ -219,7 +219,7 @@ class Transaction extends Twig_Extension
return '<span class="text-success">(cash)</span>';
}
return '<a title="' . e($name) . '" href="' . route('accounts.show', $id) . '">' . e($name) . '</a>';
return '<a title="' . e($name) . '" href="' . route('accounts.show', [$id]) . '">' . e($name) . '</a>';
}, ['is_safe' => ['html']]
);
@ -257,7 +257,7 @@ class Transaction extends Twig_Extension
return '<span class="text-success">(cash)</span>';
}
return '<a title="' . e($name) . '" href="' . route('accounts.show', $id) . '">' . e($name) . '</a>';
return '<a title="' . e($name) . '" href="' . route('accounts.show', [$id]) . '">' . e($name) . '</a>';
}, ['is_safe' => ['html']]
);