mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
Refactor journal repositories.
This commit is contained in:
@@ -26,6 +26,8 @@ use FireflyIII\Helpers\Collector\GroupCollector;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalAPIRepository;
|
||||
use FireflyIII\Repositories\Journal\JournalAPIRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepository;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepository;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository;
|
||||
@@ -63,7 +65,7 @@ class JournalServiceProvider extends ServiceProvider
|
||||
{
|
||||
$this->app->bind(
|
||||
GroupCollectorInterface::class,
|
||||
function (Application $app) {
|
||||
static function (Application $app) {
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollector::class);
|
||||
if ($app->auth->check()) {
|
||||
@@ -82,7 +84,7 @@ class JournalServiceProvider extends ServiceProvider
|
||||
{
|
||||
$this->app->bind(
|
||||
TransactionGroupRepositoryInterface::class,
|
||||
function (Application $app) {
|
||||
static function (Application $app) {
|
||||
/** @var TransactionGroupRepositoryInterface $repository */
|
||||
$repository = app(TransactionGroupRepository::class);
|
||||
if ($app->auth->check()) {
|
||||
@@ -101,7 +103,7 @@ class JournalServiceProvider extends ServiceProvider
|
||||
{
|
||||
$this->app->bind(
|
||||
JournalRepositoryInterface::class,
|
||||
function (Application $app) {
|
||||
static function (Application $app) {
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepository::class);
|
||||
if ($app->auth->check()) {
|
||||
@@ -115,7 +117,7 @@ class JournalServiceProvider extends ServiceProvider
|
||||
// also bind new API repository
|
||||
$this->app->bind(
|
||||
JournalAPIRepositoryInterface::class,
|
||||
function (Application $app) {
|
||||
static function (Application $app) {
|
||||
/** @var JournalAPIRepositoryInterface $repository */
|
||||
$repository = app(JournalAPIRepository::class);
|
||||
if ($app->auth->check()) {
|
||||
@@ -125,5 +127,19 @@ class JournalServiceProvider extends ServiceProvider
|
||||
return $repository;
|
||||
}
|
||||
);
|
||||
|
||||
// also bind new CLI repository
|
||||
$this->app->bind(
|
||||
JournalCLIRepositoryInterface::class,
|
||||
static function (Application $app) {
|
||||
/** @var JournalCLIRepositoryInterface $repository */
|
||||
$repository = app(JournalCLIRepository::class);
|
||||
if ($app->auth->check()) {
|
||||
$repository->setUser(auth()->user());
|
||||
}
|
||||
|
||||
return $repository;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user