Rewrote currency and export/import job service provider

This commit is contained in:
James Cole
2017-01-30 17:29:05 +01:00
parent eeae4d215d
commit 8263fa41dd
2 changed files with 21 additions and 21 deletions

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Currency\CurrencyRepository;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,15 @@ class CurrencyServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', CurrencyRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var CurrencyRepository $repository */
return app('FireflyIII\Repositories\Currency\CurrencyRepository', [auth()->user()]); $repository = app(CurrencyRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\Currency\CurrencyRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -15,6 +15,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\ExportJob\ExportJobRepository;
use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -33,8 +35,7 @@ class ExportJobServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
$this->exportJob();
$this->importJob();
} }
@@ -45,7 +46,8 @@ class ExportJobServiceProvider extends ServiceProvider
*/ */
public function register() public function register()
{ {
// $this->exportJob();
$this->importJob();
} }
/** /**
@@ -53,18 +55,16 @@ class ExportJobServiceProvider extends ServiceProvider
*/ */
private function exportJob() private function exportJob()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface', ExportJobRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var ExportJobRepository $repository */
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', [auth()->user()]); $repository = app(ExportJobRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', $arguments); return $repository;
} }
); );
} }