mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Register and use interface.
This commit is contained in:
parent
8417f45d02
commit
e1e94a788c
@ -15,7 +15,7 @@ namespace FireflyIII\Http\Controllers;
|
||||
use Artisan;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\JournalCollector;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
@ -143,7 +143,7 @@ class HomeController extends Controller
|
||||
$showDepositsFrontpage = Preferences::get('showDepositsFrontpage', false)->data;
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$collector = new JournalCollector(auth()->user());
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit(10)->setPage(1);
|
||||
$set = $collector->getJournals();
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user