Update the last providers.

This commit is contained in:
James Cole
2017-02-05 15:58:27 +01:00
parent 3ff83cd431
commit 152fb3f885
5 changed files with 38 additions and 38 deletions

View File

@@ -14,9 +14,10 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\ExportJob\ExportJobRepository; use FireflyIII\Repositories\ExportJob\ExportJobRepository;
use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface; use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface;
use FireflyIII\Repositories\ImportJob\ImportJobRepository;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -72,16 +73,15 @@ class ExportJobServiceProvider extends ServiceProvider
private function importJob() private function importJob()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface', ImportJobRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var ImportJobRepository $repository */
return app('FireflyIII\Repositories\ImportJob\ImportJobRepository', [auth()->user()]); $repository = app(ImportJobRepository::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\ImportJob\ImportJobRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -46,7 +46,7 @@ class RuleGroupServiceProvider extends ServiceProvider
{ {
$this->app->bind( $this->app->bind(
RuleGroupRepositoryInterface::class, RuleGroupRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
/** @var RuleGroupRepository $repository */ /** @var RuleGroupRepository $repository */
$repository = app(RuleGroupRepository::class); $repository = app(RuleGroupRepository::class);
if ($app->auth->check()) { if ($app->auth->check()) {

View File

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

View File

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

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Tag\TagRepository;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,16 @@ class TagServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Tag\TagRepositoryInterface', TagRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var TagRepository $repository */
return app('FireflyIII\Repositories\Tag\TagRepository', [auth()->user()]); $repository = app(TagRepository::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\Tag\TagRepository', $arguments); return $repository;
} }
); );
} }