mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	Rewrote currency and export/import job service provider
This commit is contained in:
		| @@ -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; | ||||||
|             } |             } | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -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; | ||||||
|             } |             } | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user