mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Avoid using model methods and use repository instead
This commit is contained in:
@@ -66,6 +66,30 @@ class TransactionJournal extends Twig_Extension
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if journal HAS field.
|
||||
*
|
||||
* @param JournalModel $journal
|
||||
* @param string $field
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasMetaField(JournalModel $journal, string $field): bool
|
||||
{
|
||||
// HIER BEN JE
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$result = $repository->getMetaField($journal, $field);
|
||||
if (is_null($result)) {
|
||||
return false;
|
||||
}
|
||||
if (strlen(strval($result)) === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JournalModel $journal
|
||||
*
|
||||
|
@@ -94,8 +94,9 @@ class Journal extends Twig_Extension
|
||||
$this->getDestinationAccount(),
|
||||
$this->journalBudgets(),
|
||||
$this->journalCategories(),
|
||||
new Twig_SimpleFunction('getMetaField', [TransactionJournalExtension::class, 'getMetaField']),
|
||||
new Twig_SimpleFunction('getMetaDate', [TransactionJournalExtension::class, 'getMetaDate']),
|
||||
new Twig_SimpleFunction('journalGetMetaField', [TransactionJournalExtension::class, 'getMetaField']),
|
||||
new Twig_SimpleFunction('journalHasMeta', [TransactionJournalExtension::class, 'hasMetaField']),
|
||||
new Twig_SimpleFunction('journalGetMetaDate', [TransactionJournalExtension::class, 'getMetaDate']),
|
||||
];
|
||||
|
||||
return $functions;
|
||||
|
Reference in New Issue
Block a user