Remove static references

This commit is contained in:
James Cole
2023-10-29 06:32:00 +01:00
parent e65d0eef6e
commit 075d459b7c
128 changed files with 391 additions and 391 deletions

View File

@@ -52,7 +52,7 @@ trait DepositValidation
// if both values are NULL we return false,
// because the destination of a deposit can't be created.
$this->destError = (string)trans('validation.deposit_dest_need_data');
Log::error('Both values are NULL, cant create deposit destination.');
app('log')->error('Both values are NULL, cant create deposit destination.');
$result = false;
}
// if the account can be created anyway we don't need to search.

View File

@@ -50,12 +50,12 @@ trait LiabilityValidation
// the ID of the destination must belong to a liability.
if (null !== $accountId) {
if (AccountType::LIABILITY_CREDIT !== $this?->source?->accountType?->type) {
Log::error('Source account is not a liability.');
app('log')->error('Source account is not a liability.');
return false;
}
$result = $this->findExistingAccount($validTypes, $array);
if (null === $result) {
Log::error('Destination account is not a liability.');
app('log')->error('Destination account is not a liability.');
return false;
}
return true;
@@ -65,7 +65,7 @@ trait LiabilityValidation
Log::debug('Destination ID is null, now we can assume the destination is a (new) liability credit account.');
return true;
}
Log::error('Destination ID is null, but destination name is also NULL.');
app('log')->error('Destination ID is null, but destination name is also NULL.');
return false;
}
@@ -87,7 +87,7 @@ trait LiabilityValidation
// find liability credit:
$result = $this->findExistingAccount(config('firefly.valid_liabilities'), $array);
if (null === $result) {
Log::error('Did not find a liability account, return false.');
app('log')->error('Did not find a liability account, return false.');
return false;
}
Log::debug(sprintf('Return true, found #%d ("%s")', $result->id, $result->name));
@@ -100,11 +100,11 @@ trait LiabilityValidation
$result = true;
if ('' === $accountName || null === $accountName) {
Log::error('Array must have a name, is not the case, return false.');
app('log')->error('Array must have a name, is not the case, return false.');
$result = false;
}
if (true === $result) {
Log::error('Array has a name, return true.');
app('log')->error('Array has a name, return true.');
// set the source to be a (dummy) revenue account.
$account = new Account();
$accountType = AccountType::whereType(AccountType::LIABILITY_CREDIT)->first();

View File

@@ -51,7 +51,7 @@ trait OBValidation
// if both values are NULL we return false,
// because the destination of a deposit can't be created.
$this->destError = (string)trans('validation.ob_dest_need_data');
Log::error('Both values are NULL, cant create OB destination.');
app('log')->error('Both values are NULL, cant create OB destination.');
$result = false;
}
// if the account can be created anyway we don't need to search.

View File

@@ -48,7 +48,7 @@ trait TransferValidation
// if both values are NULL we return false,
// because the destination of a transfer can't be created.
$this->destError = (string)trans('validation.transfer_dest_need_data');
Log::error('Both values are NULL, cant create transfer destination.');
app('log')->error('Both values are NULL, cant create transfer destination.');
return false;
}

View File

@@ -154,7 +154,7 @@ class AccountValidator
{
Log::debug('Now in AccountValidator::validateDestination()', $array);
if (null === $this->source) {
Log::error('Source is NULL, always FALSE.');
app('log')->error('Source is NULL, always FALSE.');
$this->destError = 'No source account validation has taken place yet. Please do this first or overrule the object.';
return false;
@@ -162,7 +162,7 @@ class AccountValidator
switch ($this->transactionType) {
default:
$this->destError = sprintf('AccountValidator::validateDestination cannot handle "%s", so it will always return false.', $this->transactionType);
Log::error(sprintf('AccountValidator::validateDestination cannot handle "%s", so it will always return false.', $this->transactionType));
app('log')->error(sprintf('AccountValidator::validateDestination cannot handle "%s", so it will always return false.', $this->transactionType));
$result = false;
break;
@@ -200,7 +200,7 @@ class AccountValidator
Log::debug('Now in AccountValidator::validateSource()', $array);
switch ($this->transactionType) {
default:
Log::error(sprintf('AccountValidator::validateSource cannot handle "%s", so it will do a generic check.', $this->transactionType));
app('log')->error(sprintf('AccountValidator::validateSource cannot handle "%s", so it will do a generic check.', $this->transactionType));
$result = $this->validateGenericSource($array);
break;
case TransactionType::WITHDRAWAL:

View File

@@ -53,7 +53,7 @@ trait ValidatesAdministrationAccess
throw new FireflyException('deprecated method, must be done through user.');
Log::debug('Now in validateAdministration()');
if (!auth()->check()) {
Log::error('User is not authenticated.');
app('log')->error('User is not authenticated.');
throw new AuthenticationException('No access to validateAdministration() method.');
}
/** @var User $user */
@@ -64,7 +64,7 @@ trait ValidatesAdministrationAccess
$administrationId = (int)($data['administration_id'] ?? $user->getAdministrationId());
// safety catch:
if (0 === $administrationId) {
Log::error('validateAdministration ran into empty administration ID.');
app('log')->error('validateAdministration ran into empty administration ID.');
throw new AuthenticationException('Cannot validate administration.');
}
// grab the group:
@@ -73,7 +73,7 @@ trait ValidatesAdministrationAccess
// collect the user's roles in this group:
$array = $repository->getRolesInGroup($user, $administrationId);
if (0 === count($array)) {
Log::error(sprintf('User #%d ("%s") has no membership in group #%d.', $user->id, $user->email, $administrationId));
app('log')->error(sprintf('User #%d ("%s") has no membership in group #%d.', $user->id, $user->email, $administrationId));
$validator->errors()->add('administration', (string)trans('validation.no_access_user_group'));
return;
}
@@ -92,7 +92,7 @@ trait ValidatesAdministrationAccess
}
}
if (false === $access) {
Log::error(
app('log')->error(
sprintf(
'User #%d has memberships [%s] to group #%d but needs [%s].',
$user->id,

View File

@@ -71,7 +71,7 @@ class FireflyValidator extends Validator
}
$user = auth()->user();
if (null === $user) {
Log::error('No user during validate2faCode');
app('log')->error('No user during validate2faCode');
return false;
}
$secretPreference = Preferences::get('temp-mfa-secret');
@@ -230,8 +230,8 @@ class FireflyValidator extends Validator
$checksum = bcmod($iban, '97');
} catch (ValueError $e) {
$message = sprintf('Could not validate IBAN check value "%s" (IBAN "%s")', $iban, $value);
Log::error($message);
Log::error($e->getTraceAsString());
app('log')->error($message);
app('log')->error($e->getTraceAsString());
return false;
}
@@ -432,7 +432,7 @@ class FireflyValidator extends Validator
try {
$parser->parseDate($value);
} catch (FireflyException $e) {
Log::error($e->getMessage());
app('log')->error($e->getMessage());
return false;
}

View File

@@ -94,7 +94,7 @@ trait TransactionValidation
}
// should be impossible to hit this:
if (!is_countable($transactions)) {
Log::error(sprintf('Transactions array is not countable, because its a %s', gettype($transactions)));
app('log')->error(sprintf('Transactions array is not countable, because its a %s', gettype($transactions)));
return [];
}
//Log::debug('Returning transactions.', $transactions);