Remove static references

This commit is contained in:
James Cole
2023-10-29 06:33:43 +01:00
parent 075d459b7c
commit 4f2159b54d
205 changed files with 1287 additions and 1287 deletions

View File

@@ -43,7 +43,7 @@ class APIEventHandler
*/
public function accessTokenCreated(AccessTokenCreated $event): void
{
Log::debug(__METHOD__);
app('log')->debug(__METHOD__);
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
$user = $repository->find((int)$event->userId);

View File

@@ -47,23 +47,23 @@ class AutomationHandler
*/
public function reportJournals(RequestedReportOnJournals $event): void
{
Log::debug('In reportJournals.');
app('log')->debug('In reportJournals.');
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
$user = $repository->find($event->userId);
$sendReport = app('preferences')->getForUser($user, 'notification_transaction_creation', false)->data;
if (false === $sendReport) {
Log::debug('Not sending report, because config says so.');
app('log')->debug('Not sending report, because config says so.');
return;
}
if (null === $user || 0 === $event->groups->count()) {
Log::debug('No transaction groups in event, nothing to email about.');
app('log')->debug('No transaction groups in event, nothing to email about.');
return;
}
Log::debug('Continue with message!');
app('log')->debug('Continue with message!');
// transform groups into array:
/** @var TransactionGroupTransformer $transformer */
@@ -88,6 +88,6 @@ class AutomationHandler
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
}
Log::debug('If there is no error above this line, message was sent.');
app('log')->debug('If there is no error above this line, message was sent.');
}
}

View File

@@ -43,14 +43,14 @@ class BillEventHandler
*/
public function warnAboutBill(WarnUserAboutBill $event): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
$bill = $event->bill;
/** @var bool $preference */
$preference = app('preferences')->getForUser($bill->user, 'notification_bill_reminder', true)->data;
if (true === $preference) {
Log::debug('Bill reminder is true!');
app('log')->debug('Bill reminder is true!');
try {
Notification::send($bill->user, new BillReminder($bill, $event->field, $event->diff));
} catch (Exception $e) {
@@ -68,7 +68,7 @@ class BillEventHandler
}
}
if (false === $preference) {
Log::debug('User has disabled bill reminders.');
app('log')->debug('User has disabled bill reminders.');
}
}
}

View File

@@ -40,7 +40,7 @@ class DestroyedGroupEventHandler
*/
public function triggerWebhooks(DestroyedTransactionGroup $destroyedGroupEvent): void
{
Log::debug('DestroyedTransactionGroup:triggerWebhooks');
app('log')->debug('DestroyedTransactionGroup:triggerWebhooks');
$group = $destroyedGroupEvent->transactionGroup;
$user = $group->user;
/** @var MessageGeneratorInterface $engine */

View File

@@ -51,7 +51,7 @@ class BudgetLimitHandler
*/
public function created(Created $event): void
{
Log::debug(sprintf('BudgetLimitHandler::created(#%s)', $event->budgetLimit->id));
app('log')->debug(sprintf('BudgetLimitHandler::created(#%s)', $event->budgetLimit->id));
$this->updateAvailableBudget($event->budgetLimit);
}
@@ -62,7 +62,7 @@ class BudgetLimitHandler
*/
private function updateAvailableBudget(BudgetLimit $budgetLimit): void
{
Log::debug(sprintf('Now in updateAvailableBudget(#%d)', $budgetLimit->id));
app('log')->debug(sprintf('Now in updateAvailableBudget(#%d)', $budgetLimit->id));
$budget = Budget::find($budgetLimit->budget_id);
if (null === $budget) {
app('log')->warning('Budget is null, probably deleted, find deleted version.');
@@ -113,7 +113,7 @@ class BudgetLimitHandler
)->where('transaction_currency_id', $budgetLimit->transaction_currency_id)->first();
if (null !== $availableBudget) {
Log::debug('Found 1 AB, will update.');
app('log')->debug('Found 1 AB, will update.');
$this->calculateAmount($availableBudget);
}
if (null === $availableBudget) {
@@ -127,10 +127,10 @@ class BudgetLimitHandler
$amount = 0 === (int)$budgetLimit->id ? '0' : $budgetLimit->amount;
}
if (0 === bccomp($amount, '0')) {
Log::debug('Amount is zero, will not create AB.');
app('log')->debug('Amount is zero, will not create AB.');
}
if (0 !== bccomp($amount, '0')) {
Log::debug(sprintf('Will create AB for period %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d')));
app('log')->debug(sprintf('Will create AB for period %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d')));
$availableBudget = new AvailableBudget(
[
'user_id' => $budgetLimit->budget->user->id,
@@ -161,7 +161,7 @@ class BudgetLimitHandler
$repository->setUser($availableBudget->user);
$newAmount = '0';
$abPeriod = Period::make($availableBudget->start_date, $availableBudget->end_date, Precision::DAY());
Log::debug(
app('log')->debug(
sprintf(
'Now at AB #%d, ("%s" to "%s")',
$availableBudget->id,
@@ -171,10 +171,10 @@ class BudgetLimitHandler
);
// have to recalculate everything just in case.
$set = $repository->getAllBudgetLimitsByCurrency($availableBudget->transactionCurrency, $availableBudget->start_date, $availableBudget->end_date);
Log::debug(sprintf('Found %d interesting budget limit(s).', $set->count()));
app('log')->debug(sprintf('Found %d interesting budget limit(s).', $set->count()));
/** @var BudgetLimit $budgetLimit */
foreach ($set as $budgetLimit) {
Log::debug(
app('log')->debug(
sprintf(
'Found interesting budget limit #%d ("%s" to "%s")',
$budgetLimit->id,
@@ -210,11 +210,11 @@ class BudgetLimitHandler
}
}
if (0 === bccomp('0', $newAmount)) {
Log::debug('New amount is zero, deleting AB.');
app('log')->debug('New amount is zero, deleting AB.');
$availableBudget->delete();
return;
}
Log::debug(sprintf('Concluded new amount for this AB must be %s', $newAmount));
app('log')->debug(sprintf('Concluded new amount for this AB must be %s', $newAmount));
$availableBudget->amount = app('steam')->bcround($newAmount, $availableBudget->transactionCurrency->decimal_places);
$availableBudget->save();
}
@@ -237,7 +237,7 @@ class BudgetLimitHandler
);
$days = $limitPeriod->length();
$amount = bcdiv((string)$budgetLimit->amount, (string)$days, 12);
Log::debug(
app('log')->debug(
sprintf('Total amount for budget limit #%d is %s. Nr. of days is %d. Amount per day is %s', $budgetLimit->id, $budgetLimit->amount, $days, $amount)
);
return $amount;
@@ -250,7 +250,7 @@ class BudgetLimitHandler
*/
public function deleted(Deleted $event): void
{
Log::debug(sprintf('BudgetLimitHandler::deleted(#%s)', $event->budgetLimit->id));
app('log')->debug(sprintf('BudgetLimitHandler::deleted(#%s)', $event->budgetLimit->id));
$budgetLimit = $event->budgetLimit;
$budgetLimit->id = null;
$this->updateAvailableBudget($event->budgetLimit);
@@ -263,7 +263,7 @@ class BudgetLimitHandler
*/
public function updated(Updated $event): void
{
Log::debug(sprintf('BudgetLimitHandler::updated(#%s)', $event->budgetLimit->id));
app('log')->debug(sprintf('BudgetLimitHandler::updated(#%s)', $event->budgetLimit->id));
$this->updateAvailableBudget($event->budgetLimit);
}

View File

@@ -51,7 +51,7 @@ class StoredGroupEventHandler
return;
}
Log::debug('Now in StoredGroupEventHandler::processRules()');
app('log')->debug('Now in StoredGroupEventHandler::processRules()');
$journals = $storedGroupEvent->transactionGroup->transactionJournals;
$array = [];
@@ -60,7 +60,7 @@ class StoredGroupEventHandler
$array[] = $journal->id;
}
$journalIds = implode(',', $array);
Log::debug(sprintf('Add local operator for journal(s): %s', $journalIds));
app('log')->debug(sprintf('Add local operator for journal(s): %s', $journalIds));
// collect rules:
$ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
@@ -97,7 +97,7 @@ class StoredGroupEventHandler
*/
public function triggerWebhooks(StoredTransactionGroup $storedGroupEvent): void
{
Log::debug(__METHOD__);
app('log')->debug(__METHOD__);
$group = $storedGroupEvent->transactionGroup;
if (false === $storedGroupEvent->fireWebhooks) {
app('log')->info(sprintf('Will not fire webhooks for transaction group #%d', $group->id));

View File

@@ -62,7 +62,7 @@ class UpdatedGroupEventHandler
$array[] = $journal->id;
}
$journalIds = implode(',', $array);
Log::debug(sprintf('Add local operator for journal(s): %s', $journalIds));
app('log')->debug(sprintf('Add local operator for journal(s): %s', $journalIds));
// collect rules:
$ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
@@ -95,7 +95,7 @@ class UpdatedGroupEventHandler
*/
public function triggerWebhooks(UpdatedTransactionGroup $updatedGroupEvent): void
{
Log::debug(__METHOD__);
app('log')->debug(__METHOD__);
$group = $updatedGroupEvent->transactionGroup;
if (false === $updatedGroupEvent->fireWebhooks) {
app('log')->info(sprintf('Will not fire webhooks for transaction group #%d', $group->id));

View File

@@ -73,7 +73,7 @@ class UserEventHandler
// first user ever?
if (1 === $repository->count()) {
Log::debug('User count is one, attach role.');
app('log')->debug('User count is one, attach role.');
$repository->attachRole($event->user, 'owner');
}
}
@@ -386,11 +386,11 @@ class UserEventHandler
*/
public function storeUserIPAddress(ActuallyLoggedIn $event): void
{
Log::debug('Now in storeUserIPAddress');
app('log')->debug('Now in storeUserIPAddress');
$user = $event->user;
if ($user->hasRole('demo')) {
Log::debug('Do not log demo user logins');
app('log')->debug('Do not log demo user logins');
return;
}
@@ -405,19 +405,19 @@ class UserEventHandler
}
$inArray = false;
$ip = request()->ip();
Log::debug(sprintf('User logging in from IP address %s', $ip));
app('log')->debug(sprintf('User logging in from IP address %s', $ip));
// update array if in array
foreach ($preference as $index => $row) {
if ($row['ip'] === $ip) {
Log::debug('Found IP in array, refresh time.');
app('log')->debug('Found IP in array, refresh time.');
$preference[$index]['time'] = now(config('app.timezone'))->format('Y-m-d H:i:s');
$inArray = true;
}
// clean up old entries (6 months)
$carbon = Carbon::createFromFormat('Y-m-d H:i:s', $preference[$index]['time']);
if ($carbon->diffInMonths(today()) > 6) {
Log::debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
app('log')->debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
unset($preference[$index]);
}
}

View File

@@ -51,13 +51,13 @@ class VersionCheckEventHandler
*/
public function checkForUpdates(RequestedVersionCheckStatus $event): void
{
Log::debug('Now in checkForUpdates()');
app('log')->debug('Now in checkForUpdates()');
// should not check for updates:
$permission = app('fireflyconfig')->get('permission_update_check', -1);
$value = (int)$permission->data;
if (1 !== $value) {
Log::debug('Update check is not enabled.');
app('log')->debug('Update check is not enabled.');
$this->warnToCheckForUpdates($event);
return;
@@ -67,7 +67,7 @@ class VersionCheckEventHandler
$repository = app(UserRepositoryInterface::class);
$user = $event->user;
if (!$repository->hasRole($user, 'owner')) {
Log::debug('User is not admin, done.');
app('log')->debug('User is not admin, done.');
return;
}
@@ -76,14 +76,14 @@ class VersionCheckEventHandler
$lastCheckTime = app('fireflyconfig')->get('last_update_check', time());
$now = time();
$diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Last check time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
app('log')->debug(sprintf('Last check time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
if ($diff < 604800) {
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
app('log')->debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return;
}
// last check time was more than a week ago.
Log::debug('Have not checked for a new version in a week!');
app('log')->debug('Have not checked for a new version in a week!');
$release = $this->getLatestRelease();
session()->flash($release['level'], $release['message']);
@@ -103,7 +103,7 @@ class VersionCheckEventHandler
$repository = app(UserRepositoryInterface::class);
$user = $event->user;
if (!$repository->hasRole($user, 'owner')) {
Log::debug('User is not admin, done.');
app('log')->debug('User is not admin, done.');
return;
}
@@ -112,14 +112,14 @@ class VersionCheckEventHandler
$lastCheckTime = app('fireflyconfig')->get('last_update_warning', time());
$now = time();
$diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Last warning time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
app('log')->debug(sprintf('Last warning time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
if ($diff < 604800 * 4) {
Log::debug(sprintf('Warned about updates less than four weeks ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
app('log')->debug(sprintf('Warned about updates less than four weeks ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return;
}
// last check time was more than a week ago.
Log::debug('Have warned about a new version in four weeks!');
app('log')->debug('Have warned about a new version in four weeks!');
session()->flash('info', (string)trans('firefly.disabled_but_check'));
app('fireflyconfig')->set('last_update_warning', time());

View File

@@ -37,7 +37,7 @@ class WebhookEventHandler
*/
public function sendWebhookMessages(): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
// kick off the job!
$messages = WebhookMessage::where('webhook_messages.sent', false)
->get(['webhook_messages.*'])
@@ -46,14 +46,14 @@ class WebhookEventHandler
return $message->webhookAttempts()->count() <= 2;
}
)->splice(0, 5);
Log::debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count()));
app('log')->debug(sprintf('Found %d webhook message(s) ready to be send.', $messages->count()));
foreach ($messages as $message) {
if (false === $message->sent) {
Log::debug(sprintf('Send message #%d', $message->id));
app('log')->debug(sprintf('Send message #%d', $message->id));
SendWebhookMessage::dispatch($message)->afterResponse();
}
if (false !== $message->sent) {
Log::debug(sprintf('Skip message #%d', $message->id));
app('log')->debug(sprintf('Skip message #%d', $message->id));
}
}
}