Register and use interface.

This commit is contained in:
James Cole
2016-11-20 08:57:48 +01:00
parent 8417f45d02
commit e1e94a788c
2 changed files with 19 additions and 2 deletions

View File

@@ -44,6 +44,23 @@ class JournalServiceProvider extends ServiceProvider
{
$this->registerRepository();
$this->registerTasker();
$this->registerCollector();
}
private function registerCollector() {
$this->app->bind(
'FireflyIII\Helpers\Collector\JournalCollectorInterface',
function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Helpers\Collector\JournalCollector', [auth()->user()]);
}
if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.');
}
return app('FireflyIII\Helpers\Collector\JournalCollector', $arguments);
}
);
}
private function registerRepository()