Refactor references to static facades. Improve budget controller code.

This commit is contained in:
James Cole
2018-07-14 16:08:34 +02:00
parent b8699422c8
commit 89834baf01
41 changed files with 284 additions and 246 deletions

View File

@@ -29,7 +29,6 @@ use FireflyIII\Http\Requests\AccountFormRequest;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Http\Request;
use Preferences;
/**
*
@@ -103,11 +102,11 @@ class CreateController extends Controller
app('preferences')->mark();
// update preferences if necessary:
$frontPage = Preferences::get('frontPageAccounts', [])->data;
$frontPage = app('preferences')->get('frontPageAccounts', [])->data;
if (AccountType::ASSET === $account->accountType->type && \count($frontPage) > 0) {
// @codeCoverageIgnoreStart
$frontPage[] = $account->id;
Preferences::set('frontPageAccounts', $frontPage);
app('preferences')->set('frontPageAccounts', $frontPage);
// @codeCoverageIgnoreEnd
}
// redirect to previous URL.

View File

@@ -29,7 +29,6 @@ use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Preferences;
/**
*
@@ -75,7 +74,7 @@ class IndexController extends Controller
$collection = $this->repository->getAccountsByType($types);
$total = $collection->count();
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
unset($collection);
/** @var Carbon $start */

View File

@@ -38,7 +38,6 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
use Log;
use Preferences;
/**
* Class ReconcileController.
@@ -138,7 +137,7 @@ class ReconcileController extends Controller
}
// no start or end:
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
// get start and end
if (null === $start && null === $end) {

View File

@@ -36,7 +36,6 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Preferences;
use View;
/**
@@ -100,7 +99,7 @@ class ShowController extends Controller
$today = new Carbon;
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) {
@@ -146,7 +145,7 @@ class ShowController extends Controller
$start = $this->repository->oldestJournalDate($account);
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) {
@@ -187,7 +186,7 @@ class ShowController extends Controller
*/
private function getPeriodOverview(Account $account, ?Carbon $date): Collection
{
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = $this->repository->oldestJournalDate($account);
$end = $date ?? new Carbon;
if ($end < $start) {