mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Clean up some code.
This commit is contained in:
@@ -289,6 +289,7 @@ class ExpandedForm
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -299,7 +300,7 @@ class ExpandedForm
|
||||
$classes = $this->getHolderClasses($name);
|
||||
|
||||
try {
|
||||
$html = view('form.password', compact('classes', 'value','name', 'label', 'options'))->render();
|
||||
$html = view('form.password', compact('classes', 'value', 'name', 'label', 'options'))->render();
|
||||
} catch (\Throwable $e) {
|
||||
app('log')->debug(sprintf('Could not render passwordWithValue(): %s', $e->getMessage()));
|
||||
$html = 'Could not render passwordWithValue.';
|
||||
|
||||
@@ -37,7 +37,7 @@ class FireflyConfig
|
||||
{
|
||||
public function delete(string $name): void
|
||||
{
|
||||
$fullName = 'ff-config-' . $name;
|
||||
$fullName = 'ff-config-'.$name;
|
||||
if (\Cache::has($fullName)) {
|
||||
\Cache::forget($fullName);
|
||||
}
|
||||
@@ -57,14 +57,18 @@ class FireflyConfig
|
||||
}
|
||||
if ('' === $result->data) {
|
||||
Log::warning(sprintf('Empty encrypted configuration value found: "%s"', $name));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
try {
|
||||
$result->data = decrypt($result->data);
|
||||
} catch (DecryptException $e) {
|
||||
Log::error(sprintf('Could not decrypt configuration value "%s": %s', $name, $e->getMessage()));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -75,7 +79,7 @@ class FireflyConfig
|
||||
*/
|
||||
public function get(string $name, $default = null): ?Configuration
|
||||
{
|
||||
$fullName = 'ff-config-' . $name;
|
||||
$fullName = 'ff-config-'.$name;
|
||||
if (\Cache::has($fullName)) {
|
||||
return \Cache::get($fullName);
|
||||
}
|
||||
@@ -83,7 +87,7 @@ class FireflyConfig
|
||||
try {
|
||||
/** @var null|Configuration $config */
|
||||
$config = Configuration::where('name', $name)->first(['id', 'name', 'data']);
|
||||
} catch (\Exception | QueryException $e) {
|
||||
} catch (\Exception|QueryException $e) {
|
||||
throw new FireflyException(sprintf('Could not poll the database: %s', $e->getMessage()), 0, $e);
|
||||
}
|
||||
|
||||
@@ -106,8 +110,10 @@ class FireflyConfig
|
||||
$encrypted = encrypt($value);
|
||||
} catch (EncryptException $e) {
|
||||
Log::error(sprintf('Could not encrypt configuration value "%s": %s', $name, $e->getMessage()));
|
||||
|
||||
throw new FireflyException(sprintf('Could not encrypt configuration value "%s". Cowardly refuse to continue.', $name));
|
||||
}
|
||||
|
||||
return $this->set($name, $encrypted);
|
||||
}
|
||||
|
||||
@@ -129,13 +135,13 @@ class FireflyConfig
|
||||
$item->name = $name;
|
||||
$item->data = $value;
|
||||
$item->save();
|
||||
\Cache::forget('ff-config-' . $name);
|
||||
\Cache::forget('ff-config-'.$name);
|
||||
|
||||
return $item;
|
||||
}
|
||||
$config->data = $value;
|
||||
$config->save();
|
||||
\Cache::forget('ff-config-' . $name);
|
||||
\Cache::forget('ff-config-'.$name);
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
@@ -155,8 +155,9 @@ class AccountForm
|
||||
*/
|
||||
public function assetLiabilityMultiAccountList(string $name, $value = null, ?array $options = null): string
|
||||
{
|
||||
$types = [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value,AccountTypeEnum::LOAN->value];
|
||||
$types = [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value];
|
||||
$grouped = $this->getAccountsGrouped($types);
|
||||
|
||||
return $this->multiSelect($name, $grouped, $value, $options);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,14 +64,18 @@ class Preferences
|
||||
}
|
||||
if ('' === $result->data) {
|
||||
Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
try {
|
||||
$result->data = decrypt($result->data);
|
||||
} catch (DecryptException $e) {
|
||||
Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -81,12 +85,13 @@ class Preferences
|
||||
$encrypted = encrypt($value);
|
||||
} catch (EncryptException $e) {
|
||||
Log::error(sprintf('Could not encrypt preference "%s": %s', $name, $e->getMessage()));
|
||||
|
||||
throw new FireflyException(sprintf('Could not encrypt preference "%s". Cowardly refuse to continue.', $name));
|
||||
}
|
||||
|
||||
return $this->set($name, $encrypted);
|
||||
}
|
||||
|
||||
|
||||
public function get(string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
{
|
||||
/** @var null|User $user */
|
||||
|
||||
Reference in New Issue
Block a user