mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Clean up references to static Facade.
This commit is contained in:
parent
8fde16422e
commit
369839e012
@ -34,7 +34,6 @@ use League\Fractal\Manager;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Serializer\JsonApiSerializer;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -60,7 +59,7 @@ class PreferenceController extends Controller
|
||||
];
|
||||
$preferences = new Collection;
|
||||
foreach ($available as $name) {
|
||||
$pref = Preferences::getForUser($user, $name);
|
||||
$pref = app('preferences')->getForUser($user, $name);
|
||||
if (null !== $pref) {
|
||||
$preferences->push($pref);
|
||||
}
|
||||
@ -130,7 +129,7 @@ class PreferenceController extends Controller
|
||||
$newValue = 1 === (int)$data['data'];
|
||||
break;
|
||||
}
|
||||
$result = Preferences::set($preference->name, $newValue);
|
||||
$result = app('preferences')->set($preference->name, $newValue);
|
||||
|
||||
// create some objects:
|
||||
$manager = new Manager;
|
||||
|
@ -34,7 +34,6 @@ use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class CreateImport.
|
||||
@ -232,7 +231,7 @@ class CreateImport extends Command
|
||||
}
|
||||
}
|
||||
// clear cache for user:
|
||||
Preferences::setForUser($user, 'lastActivity', microtime());
|
||||
app('preferences')->setForUser($user, 'lastActivity', microtime());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Schema;
|
||||
use UnexpectedValueException;
|
||||
|
||||
@ -110,10 +109,10 @@ class UpgradeDatabase extends Command
|
||||
{
|
||||
foreach (User::get() as $user) {
|
||||
/** @var Preference $lang */
|
||||
$lang = Preferences::getForUser($user, 'language', 'en_US');
|
||||
$lang = app('preferences')->getForUser($user, 'language', 'en_US');
|
||||
$groupName = (string)trans('firefly.rulegroup_for_bills_title', [], $lang->data);
|
||||
$ruleGroup = $user->ruleGroups()->where('title', $groupName)->first();
|
||||
$currencyPreference = Preferences::getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$currencyPreference = app('preferences')->getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
|
||||
if (null === $currencyPreference) {
|
||||
$this->error('User has no currency preference. Impossible.');
|
||||
@ -294,7 +293,7 @@ class UpgradeDatabase extends Command
|
||||
function (Account $account) use ($repository) {
|
||||
$repository->setUser($account->user);
|
||||
// get users preference, fall back to system pref.
|
||||
$defaultCurrencyCode = Preferences::getForUser($account->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;
|
||||
$defaultCurrencyCode = app('preferences')->getForUser($account->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;
|
||||
$defaultCurrency = TransactionCurrency::where('code', $defaultCurrencyCode)->first();
|
||||
$accountCurrency = (int)$repository->getMetaValue($account, 'currency_id');
|
||||
$openingBalance = $account->getOpeningBalance();
|
||||
|
@ -25,7 +25,6 @@ namespace FireflyIII\Console\Commands;
|
||||
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Trait VerifiesAccessToken.
|
||||
@ -61,7 +60,7 @@ trait VerifiesAccessToken
|
||||
|
||||
return false;
|
||||
}
|
||||
$accessToken = Preferences::getForUser($user, 'access_token', null);
|
||||
$accessToken = app('preferences')->getForUser($user, 'access_token', null);
|
||||
if (null === $accessToken) {
|
||||
Log::error(sprintf('User #%d has no access token, so cannot access command line options.', $userId));
|
||||
|
||||
|
@ -42,7 +42,6 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Schema;
|
||||
use stdClass;
|
||||
|
||||
@ -106,10 +105,10 @@ class VerifyDatabase extends Command
|
||||
$users = User::get();
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
$pref = Preferences::getForUser($user, 'access_token', null);
|
||||
$pref = app('preferences')->getForUser($user, 'access_token', null);
|
||||
if (null === $pref) {
|
||||
$token = $user->generateAccessToken();
|
||||
Preferences::setForUser($user, 'access_token', $token);
|
||||
app('preferences')->setForUser($user, 'access_token', $token);
|
||||
$this->line(sprintf('Generated access token for user %s', $user->email));
|
||||
++$count;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ use FireflyIII\User;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Log;
|
||||
use Mail;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class UserEventHandler.
|
||||
@ -138,7 +137,7 @@ class UserEventHandler
|
||||
$oldEmail = $event->oldEmail;
|
||||
$user = $event->user;
|
||||
$ipAddress = $event->ipAddress;
|
||||
$token = Preferences::getForUser($user, 'email_change_confirm_token', 'invalid');
|
||||
$token = app('preferences')->getForUser($user, 'email_change_confirm_token', 'invalid');
|
||||
$uri = route('profile.confirm-email-change', [$token->data]);
|
||||
try {
|
||||
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
|
||||
@ -164,7 +163,7 @@ class UserEventHandler
|
||||
$oldEmail = $event->oldEmail;
|
||||
$user = $event->user;
|
||||
$ipAddress = $event->ipAddress;
|
||||
$token = Preferences::getForUser($user, 'email_change_undo_token', 'invalid');
|
||||
$token = app('preferences')->getForUser($user, 'email_change_undo_token', 'invalid');
|
||||
$uri = route('profile.undo-email-change', [$token->data, hash('sha256', $oldEmail)]);
|
||||
try {
|
||||
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Helpers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class FiscalHelper.
|
||||
@ -38,7 +37,7 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->useCustomFiscalYear = Preferences::get('customFiscalYear', false)->data;
|
||||
$this->useCustomFiscalYear = app('preferences')->get('customFiscalYear', false)->data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +71,7 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
// get start mm-dd. Then create a start date in the year passed.
|
||||
$startDate = clone $date;
|
||||
if (true === $this->useCustomFiscalYear) {
|
||||
$prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
|
||||
$prefStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data;
|
||||
[$mth, $day] = explode('-', $prefStartStr);
|
||||
$startDate->month((int)$mth)->day((int)$day);
|
||||
|
||||
|
@ -30,7 +30,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
*
|
||||
* @property string $type
|
||||
* @method whereType(string $type)
|
||||
* @property int $id
|
||||
* @property int $id
|
||||
*
|
||||
*/
|
||||
class AccountType extends Model
|
||||
|
@ -50,7 +50,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property int $skip
|
||||
* @property bool $automatch
|
||||
* @property User $user
|
||||
* @property string $match
|
||||
* @property string $match
|
||||
*/
|
||||
class Bill extends Model
|
||||
{
|
||||
|
@ -32,10 +32,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class Budget.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property bool $active
|
||||
* @property int $user_id
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property bool $active
|
||||
* @property int $user_id
|
||||
* @property-read string $email
|
||||
*/
|
||||
class Budget extends Model
|
||||
|
@ -40,7 +40,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property string $file_type
|
||||
* @property int $tag_id
|
||||
* @property Tag $tag
|
||||
* @property array $errors
|
||||
* @property array $errors
|
||||
*/
|
||||
class ImportJob extends Model
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property Carbon $updated_at
|
||||
* @property string $text
|
||||
* @property string $title
|
||||
* @property int $noteable_id
|
||||
* @property int $noteable_id
|
||||
*/
|
||||
class Note extends Model
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ class RecurrenceTransaction extends Model
|
||||
*/
|
||||
public function destinationAccount(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Account::class,'destination_id');
|
||||
return $this->belongsTo(Account::class, 'destination_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,7 +109,7 @@ class RecurrenceTransaction extends Model
|
||||
*/
|
||||
public function sourceAccount(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Account::class,'source_id');
|
||||
return $this->belongsTo(Account::class, 'source_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,14 +32,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class RuleGroup.
|
||||
*
|
||||
* @property bool $active
|
||||
* @property User $user
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property string $title
|
||||
* @property string $text
|
||||
* @property int $id
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property User $user
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property string $title
|
||||
* @property string $text
|
||||
* @property int $id
|
||||
* @property int $order
|
||||
* @property Collection $rules
|
||||
*/
|
||||
class RuleGroup extends Model
|
||||
|
@ -34,7 +34,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
@ -396,7 +395,7 @@ class TransactionJournal extends Model
|
||||
}
|
||||
$entry->data = $value;
|
||||
$entry->save();
|
||||
Preferences::mark();
|
||||
app('preferences')->mark();
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property string $name
|
||||
* @property int $transaction_journal_id
|
||||
* @property TransactionJournal $transactionJournal
|
||||
* @property string $data
|
||||
* @property int $id
|
||||
* @property string $data
|
||||
* @property int $id
|
||||
*/
|
||||
class TransactionJournalMeta extends Model
|
||||
{
|
||||
|
@ -32,7 +32,6 @@ use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class CurrencyRepository.
|
||||
@ -66,7 +65,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
// is the default currency for the user or the system
|
||||
$defaultCode = Preferences::getForUser($this->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;
|
||||
$defaultCode = app('preferences')->getForUser($this->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;
|
||||
if ($currency->code === $defaultCode) {
|
||||
return false;
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class JournalRepository.
|
||||
@ -107,7 +106,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$journal->save();
|
||||
}
|
||||
|
||||
Preferences::mark();
|
||||
app('preferences')->mark();
|
||||
|
||||
return new MessageBag;
|
||||
}
|
||||
|
@ -63,13 +63,6 @@ interface LinkTypeRepositoryInterface
|
||||
*/
|
||||
public function find(int $id): LinkType;
|
||||
|
||||
/**
|
||||
* Set the user for this instance.
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void;
|
||||
|
||||
/**
|
||||
* Find link type by name.
|
||||
*
|
||||
@ -128,6 +121,13 @@ interface LinkTypeRepositoryInterface
|
||||
*/
|
||||
public function getLinks(TransactionJournal $journal): Collection;
|
||||
|
||||
/**
|
||||
* Set the user for this instance.
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
|
@ -27,7 +27,6 @@ use FireflyIII\Models\Role;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class UserRepository.
|
||||
@ -73,12 +72,12 @@ class UserRepository implements UserRepositoryInterface
|
||||
$oldEmail = $user->email;
|
||||
|
||||
// save old email as pref
|
||||
Preferences::setForUser($user, 'previous_email_latest', $oldEmail);
|
||||
Preferences::setForUser($user, 'previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);
|
||||
app('preferences')->setForUser($user, 'previous_email_latest', $oldEmail);
|
||||
app('preferences')->setForUser($user, 'previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);
|
||||
|
||||
// set undo and confirm token:
|
||||
Preferences::setForUser($user, 'email_change_undo_token', (string)bin2hex(random_bytes(16)));
|
||||
Preferences::setForUser($user, 'email_change_confirm_token', (string)bin2hex(random_bytes(16)));
|
||||
app('preferences')->setForUser($user, 'email_change_undo_token', (string)bin2hex(random_bytes(16)));
|
||||
app('preferences')->setForUser($user, 'email_change_confirm_token', (string)bin2hex(random_bytes(16)));
|
||||
// update user
|
||||
|
||||
$user->email = $newEmail;
|
||||
@ -222,8 +221,8 @@ class UserRepository implements UserRepositoryInterface
|
||||
$return = [];
|
||||
|
||||
// two factor:
|
||||
$is2faEnabled = Preferences::getForUser($user, 'twoFactorAuthEnabled', false)->data;
|
||||
$has2faSecret = null !== Preferences::getForUser($user, 'twoFactorAuthSecret');
|
||||
$is2faEnabled = app('preferences')->getForUser($user, 'twoFactorAuthEnabled', false)->data;
|
||||
$has2faSecret = null !== app('preferences')->getForUser($user, 'twoFactorAuthSecret');
|
||||
$return['has_2fa'] = false;
|
||||
if ($is2faEnabled && $has2faSecret) {
|
||||
$return['has_2fa'] = true;
|
||||
@ -329,8 +328,8 @@ class UserRepository implements UserRepositoryInterface
|
||||
$oldEmail = $user->email;
|
||||
|
||||
// save old email as pref
|
||||
Preferences::setForUser($user, 'admin_previous_email_latest', $oldEmail);
|
||||
Preferences::setForUser($user, 'admin_previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);
|
||||
app('preferences')->setForUser($user, 'admin_previous_email_latest', $oldEmail);
|
||||
app('preferences')->setForUser($user, 'admin_previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);
|
||||
|
||||
$user->email = $newEmail;
|
||||
$user->save();
|
||||
|
@ -123,9 +123,9 @@ class BunqInformation implements InformationInterface
|
||||
private function closeSession(SessionToken $sessionToken): void
|
||||
{
|
||||
Log::debug('Going to close session');
|
||||
$apiKey = Preferences::getForUser($this->user, 'bunq_api_key')->data;
|
||||
$serverPublicKey = Preferences::getForUser($this->user, 'bunq_server_public_key')->data;
|
||||
$privateKey = Preferences::getForUser($this->user, 'bunq_private_key')->data;
|
||||
$apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
|
||||
$serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
|
||||
$privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
|
||||
$request = new DeleteDeviceSessionRequest();
|
||||
$request->setSecret($apiKey);
|
||||
$request->setPrivateKey($privateKey);
|
||||
@ -144,9 +144,9 @@ class BunqInformation implements InformationInterface
|
||||
*/
|
||||
private function getMonetaryAccounts(SessionToken $sessionToken, int $userId): Collection
|
||||
{
|
||||
$apiKey = Preferences::getForUser($this->user, 'bunq_api_key')->data;
|
||||
$serverPublicKey = Preferences::getForUser($this->user, 'bunq_server_public_key')->data;
|
||||
$privateKey = Preferences::getForUser($this->user, 'bunq_private_key')->data;
|
||||
$apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
|
||||
$serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
|
||||
$privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
|
||||
$request = new ListMonetaryAccountRequest;
|
||||
|
||||
$request->setSessionToken($sessionToken);
|
||||
@ -168,9 +168,9 @@ class BunqInformation implements InformationInterface
|
||||
*/
|
||||
private function getUserInformation(SessionToken $sessionToken): int
|
||||
{
|
||||
$apiKey = Preferences::getForUser($this->user, 'bunq_api_key')->data;
|
||||
$serverPublicKey = Preferences::getForUser($this->user, 'bunq_server_public_key')->data;
|
||||
$privateKey = Preferences::getForUser($this->user, 'bunq_private_key')->data;
|
||||
$apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
|
||||
$serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
|
||||
$privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
|
||||
$request = new ListUserRequest;
|
||||
$request->setSessionToken($sessionToken);
|
||||
$request->setSecret($apiKey);
|
||||
@ -196,10 +196,10 @@ class BunqInformation implements InformationInterface
|
||||
private function startSession(): SessionToken
|
||||
{
|
||||
Log::debug('Now in startSession.');
|
||||
$apiKey = Preferences::getForUser($this->user, 'bunq_api_key')->data;
|
||||
$serverPublicKey = Preferences::getForUser($this->user, 'bunq_server_public_key')->data;
|
||||
$privateKey = Preferences::getForUser($this->user, 'bunq_private_key')->data;
|
||||
$installationToken = Preferences::getForUser($this->user, 'bunq_installation_token')->data;
|
||||
$apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
|
||||
$serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
|
||||
$privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
|
||||
$installationToken = app('preferences')->getForUser($this->user, 'bunq_installation_token')->data;
|
||||
$request = new DeviceSessionRequest();
|
||||
$request->setSecret($apiKey);
|
||||
$request->setServerPublicKey($serverPublicKey);
|
||||
|
Loading…
Reference in New Issue
Block a user