Code cleanup.

This commit is contained in:
James Cole 2016-04-28 05:50:29 +02:00
parent 2d368f226e
commit 19d7e27fa9
13 changed files with 42 additions and 71 deletions

View File

@ -35,10 +35,9 @@ class AccountServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Account\AccountRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Account\AccountRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Account\AccountRepository', $arguments); return app('FireflyIII\Repositories\Account\AccountRepository', $arguments);

View File

@ -35,10 +35,9 @@ class AttachmentServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Attachment\AttachmentRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Attachment\AttachmentRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Attachment\AttachmentRepository', $arguments); return app('FireflyIII\Repositories\Attachment\AttachmentRepository', $arguments);

View File

@ -35,10 +35,9 @@ class BillServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Bill\BillRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Bill\BillRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Bill\BillRepository', $arguments); return app('FireflyIII\Repositories\Bill\BillRepository', $arguments);

View File

@ -35,10 +35,9 @@ class BudgetServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Budget\BudgetRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Budget\BudgetRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Budget\BudgetRepository', $arguments); return app('FireflyIII\Repositories\Budget\BudgetRepository', $arguments);

View File

@ -35,10 +35,9 @@ class CategoryServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Category\CategoryRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Category\CategoryRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Category\CategoryRepository', $arguments); return app('FireflyIII\Repositories\Category\CategoryRepository', $arguments);
@ -50,10 +49,9 @@ class CategoryServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Category\SingleCategoryRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Category\SingleCategoryRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Category\SingleCategoryRepository', $arguments); return app('FireflyIII\Repositories\Category\SingleCategoryRepository', $arguments);

View File

@ -86,13 +86,13 @@ class EventServiceProvider extends ServiceProvider
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error('Trying to save new LimitRepetition failed: ' . $e->getMessage()); Log::error('Trying to save new LimitRepetition failed: ' . $e->getMessage());
} }
} else { }
if ($set->count() == 1) {
$repetition = $set->first(); if ($set->count() == 1) {
$repetition->amount = $budgetLimit->amount; $repetition = $set->first();
$repetition->save(); $repetition->amount = $budgetLimit->amount;
$repetition->save();
}
} }
} }
); );

View File

@ -26,10 +26,9 @@ class ExportJobServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', $arguments); return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', $arguments);

View File

@ -34,10 +34,6 @@ class FireflyServiceProvider extends ServiceProvider
return new FireflyValidator($translator, $data, $rules, $messages); return new FireflyValidator($translator, $data, $rules, $messages);
} }
); );
/*
* Default Twig configuration:
*/
$config = app('config'); $config = app('config');
Twig::addExtension(new Functions($config)); Twig::addExtension(new Functions($config));
Twig::addExtension(new PiggyBank); Twig::addExtension(new PiggyBank);
@ -53,7 +49,6 @@ class FireflyServiceProvider extends ServiceProvider
*/ */
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'preferences', function () { 'preferences', function () {
return new Preferences; return new Preferences;
@ -81,18 +76,11 @@ class FireflyServiceProvider extends ServiceProvider
} }
); );
$this->app->bind('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', 'FireflyIII\Repositories\Currency\CurrencyRepository'); $this->app->bind('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', 'FireflyIII\Repositories\Currency\CurrencyRepository');
$this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search'); $this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search');
$this->app->bind('FireflyIII\Repositories\User\UserRepositoryInterface', 'FireflyIII\Repositories\User\UserRepository'); $this->app->bind('FireflyIII\Repositories\User\UserRepositoryInterface', 'FireflyIII\Repositories\User\UserRepository');
// CSV import
$this->app->bind('FireflyIII\Helpers\Csv\WizardInterface', 'FireflyIII\Helpers\Csv\Wizard'); $this->app->bind('FireflyIII\Helpers\Csv\WizardInterface', 'FireflyIII\Helpers\Csv\Wizard');
// attachments
$this->app->bind('FireflyIII\Helpers\Attachments\AttachmentHelperInterface', 'FireflyIII\Helpers\Attachments\AttachmentHelper'); $this->app->bind('FireflyIII\Helpers\Attachments\AttachmentHelperInterface', 'FireflyIII\Helpers\Attachments\AttachmentHelper');
// make charts:
$this->app->bind( $this->app->bind(
'FireflyIII\Generator\Chart\Account\AccountChartGeneratorInterface', 'FireflyIII\Generator\Chart\Account\ChartJsAccountChartGenerator' 'FireflyIII\Generator\Chart\Account\AccountChartGeneratorInterface', 'FireflyIII\Generator\Chart\Account\ChartJsAccountChartGenerator'
); );
@ -105,18 +93,13 @@ class FireflyServiceProvider extends ServiceProvider
'FireflyIII\Generator\Chart\PiggyBank\PiggyBankChartGeneratorInterface', 'FireflyIII\Generator\Chart\PiggyBank\ChartJsPiggyBankChartGenerator' 'FireflyIII\Generator\Chart\PiggyBank\PiggyBankChartGeneratorInterface', 'FireflyIII\Generator\Chart\PiggyBank\ChartJsPiggyBankChartGenerator'
); );
$this->app->bind('FireflyIII\Generator\Chart\Report\ReportChartGeneratorInterface', 'FireflyIII\Generator\Chart\Report\ChartJsReportChartGenerator'); $this->app->bind('FireflyIII\Generator\Chart\Report\ReportChartGeneratorInterface', 'FireflyIII\Generator\Chart\Report\ChartJsReportChartGenerator');
$this->app->bind('FireflyIII\Helpers\Help\HelpInterface', 'FireflyIII\Helpers\Help\Help'); $this->app->bind('FireflyIII\Helpers\Help\HelpInterface', 'FireflyIII\Helpers\Help\Help');
$this->app->bind('FireflyIII\Helpers\Report\ReportHelperInterface', 'FireflyIII\Helpers\Report\ReportHelper'); $this->app->bind('FireflyIII\Helpers\Report\ReportHelperInterface', 'FireflyIII\Helpers\Report\ReportHelper');
$this->app->bind('FireflyIII\Helpers\Report\ReportQueryInterface', 'FireflyIII\Helpers\Report\ReportQuery'); $this->app->bind('FireflyIII\Helpers\Report\ReportQueryInterface', 'FireflyIII\Helpers\Report\ReportQuery');
$this->app->bind('FireflyIII\Helpers\FiscalHelperInterface', 'FireflyIII\Helpers\FiscalHelper'); $this->app->bind('FireflyIII\Helpers\FiscalHelperInterface', 'FireflyIII\Helpers\FiscalHelper');
// better report helper interfaces:
$this->app->bind('FireflyIII\Helpers\Report\AccountReportHelperInterface', 'FireflyIII\Helpers\Report\AccountReportHelper'); $this->app->bind('FireflyIII\Helpers\Report\AccountReportHelperInterface', 'FireflyIII\Helpers\Report\AccountReportHelper');
$this->app->bind('FireflyIII\Helpers\Report\BalanceReportHelperInterface', 'FireflyIII\Helpers\Report\BalanceReportHelper'); $this->app->bind('FireflyIII\Helpers\Report\BalanceReportHelperInterface', 'FireflyIII\Helpers\Report\BalanceReportHelper');
$this->app->bind('FireflyIII\Helpers\Report\BudgetReportHelperInterface', 'FireflyIII\Helpers\Report\BudgetReportHelper'); $this->app->bind('FireflyIII\Helpers\Report\BudgetReportHelperInterface', 'FireflyIII\Helpers\Report\BudgetReportHelper');
} }
} }

View File

@ -35,10 +35,9 @@ class JournalServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Journal\JournalRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Journal\JournalRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Journal\JournalRepository', $arguments); return app('FireflyIII\Repositories\Journal\JournalRepository', $arguments);

View File

@ -36,10 +36,9 @@ class PiggyBankServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\PiggyBank\PiggyBankRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\PiggyBank\PiggyBankRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\PiggyBank\PiggyBankRepository', $arguments); return app('FireflyIII\Repositories\PiggyBank\PiggyBankRepository', $arguments);

View File

@ -36,10 +36,9 @@ class RuleGroupServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\RuleGroup\RuleGroupRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\RuleGroup\RuleGroupRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\RuleGroup\RuleGroupRepository', $arguments); return app('FireflyIII\Repositories\RuleGroup\RuleGroupRepository', $arguments);

View File

@ -35,10 +35,9 @@ class RuleServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Rule\RuleRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Rule\RuleRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Rule\RuleRepository', $arguments); return app('FireflyIII\Repositories\Rule\RuleRepository', $arguments);

View File

@ -35,10 +35,9 @@ class TagServiceProvider extends ServiceProvider
function (Application $app, array $arguments) { function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) { if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\Tag\TagRepository', [$app->auth->user()]); return app('FireflyIII\Repositories\Tag\TagRepository', [$app->auth->user()]);
} else { }
if (!isset($arguments[0]) && !$app->auth->check()) { if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); throw new FireflyException('There is no user present.');
}
} }
return app('FireflyIII\Repositories\Tag\TagRepository', $arguments); return app('FireflyIII\Repositories\Tag\TagRepository', $arguments);