mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 04:46:44 +00:00
Rewrote account service provider.
This commit is contained in:
@@ -14,7 +14,10 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Providers;
|
namespace FireflyIII\Providers;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Repositories\Account\AccountRepository;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Account\AccountTasker;
|
||||||
|
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
@@ -44,8 +47,6 @@ class AccountServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
$this->registerRepository();
|
$this->registerRepository();
|
||||||
$this->registerTasker();
|
$this->registerTasker();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,16 +55,16 @@ class AccountServiceProvider extends ServiceProvider
|
|||||||
private function registerRepository()
|
private function registerRepository()
|
||||||
{
|
{
|
||||||
$this->app->bind(
|
$this->app->bind(
|
||||||
'FireflyIII\Repositories\Account\AccountRepositoryInterface',
|
AccountRepositoryInterface::class,
|
||||||
function (Application $app, array $arguments) {
|
function (Application $app) {
|
||||||
if (!isset($arguments[0]) && $app->auth->check()) {
|
/** @var AccountRepositoryInterface $repository */
|
||||||
return app('FireflyIII\Repositories\Account\AccountRepository', [auth()->user()]);
|
$repository = app(AccountRepository::class);
|
||||||
}
|
|
||||||
if (!isset($arguments[0]) && !$app->auth->check()) {
|
if ($app->auth->check()) {
|
||||||
throw new FireflyException('There is no user present.');
|
$repository->setUser(auth()->user());
|
||||||
}
|
}
|
||||||
|
|
||||||
return app('FireflyIII\Repositories\Account\AccountRepository', $arguments);
|
return $repository;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -74,16 +75,16 @@ class AccountServiceProvider extends ServiceProvider
|
|||||||
private function registerTasker()
|
private function registerTasker()
|
||||||
{
|
{
|
||||||
$this->app->bind(
|
$this->app->bind(
|
||||||
'FireflyIII\Repositories\Account\AccountTaskerInterface',
|
AccountTaskerInterface::class,
|
||||||
function (Application $app, array $arguments) {
|
function (Application $app) {
|
||||||
if (!isset($arguments[0]) && $app->auth->check()) {
|
/** @var AccountTaskerInterface $tasker */
|
||||||
return app('FireflyIII\Repositories\Account\AccountTasker', [auth()->user()]);
|
$tasker = app(AccountTasker::class);
|
||||||
}
|
|
||||||
if (!isset($arguments[0]) && !$app->auth->check()) {
|
if ($app->auth->check()) {
|
||||||
throw new FireflyException('There is no user present.');
|
$tasker->setUser(auth()->user());
|
||||||
}
|
}
|
||||||
|
|
||||||
return app('FireflyIII\Repositories\Account\AccountTasker', $arguments);
|
return $tasker;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user