mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-04 05:15:39 +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;
 | 
			
		||||
 | 
			
		||||
use FireflyIII\Exceptions\FireflyException;
 | 
			
		||||
use FireflyIII\Repositories\Currency\CurrencyRepository;
 | 
			
		||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
 | 
			
		||||
use Illuminate\Foundation\Application;
 | 
			
		||||
use Illuminate\Support\ServiceProvider;
 | 
			
		||||
 | 
			
		||||
@@ -43,16 +44,15 @@ class CurrencyServiceProvider extends ServiceProvider
 | 
			
		||||
    public function register()
 | 
			
		||||
    {
 | 
			
		||||
        $this->app->bind(
 | 
			
		||||
            'FireflyIII\Repositories\Currency\CurrencyRepositoryInterface',
 | 
			
		||||
            function (Application $app, array $arguments) {
 | 
			
		||||
                if (!isset($arguments[0]) && $app->auth->check()) {
 | 
			
		||||
                    return app('FireflyIII\Repositories\Currency\CurrencyRepository', [auth()->user()]);
 | 
			
		||||
                }
 | 
			
		||||
                if (!isset($arguments[0]) && !$app->auth->check()) {
 | 
			
		||||
                    throw new FireflyException('There is no user present.');
 | 
			
		||||
            CurrencyRepositoryInterface::class,
 | 
			
		||||
            function (Application $app) {
 | 
			
		||||
                /** @var CurrencyRepository $repository */
 | 
			
		||||
                $repository = app(CurrencyRepository::class);
 | 
			
		||||
                if ($app->auth->check()) {
 | 
			
		||||
                    $repository->setUser(auth()->user());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return app('FireflyIII\Repositories\Currency\CurrencyRepository', $arguments);
 | 
			
		||||
                return $repository;
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,8 @@ declare(strict_types = 1);
 | 
			
		||||
namespace FireflyIII\Providers;
 | 
			
		||||
 | 
			
		||||
use FireflyIII\Exceptions\FireflyException;
 | 
			
		||||
use FireflyIII\Repositories\ExportJob\ExportJobRepository;
 | 
			
		||||
use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface;
 | 
			
		||||
use Illuminate\Foundation\Application;
 | 
			
		||||
use Illuminate\Support\ServiceProvider;
 | 
			
		||||
 | 
			
		||||
@@ -33,8 +35,7 @@ class ExportJobServiceProvider extends ServiceProvider
 | 
			
		||||
     */
 | 
			
		||||
    public function boot()
 | 
			
		||||
    {
 | 
			
		||||
        $this->exportJob();
 | 
			
		||||
        $this->importJob();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -45,7 +46,8 @@ class ExportJobServiceProvider extends ServiceProvider
 | 
			
		||||
     */
 | 
			
		||||
    public function register()
 | 
			
		||||
    {
 | 
			
		||||
        //
 | 
			
		||||
        $this->exportJob();
 | 
			
		||||
        $this->importJob();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -53,18 +55,16 @@ class ExportJobServiceProvider extends ServiceProvider
 | 
			
		||||
     */
 | 
			
		||||
    private function exportJob()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $this->app->bind(
 | 
			
		||||
            'FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface',
 | 
			
		||||
            function (Application $app, array $arguments) {
 | 
			
		||||
                if (!isset($arguments[0]) && $app->auth->check()) {
 | 
			
		||||
                    return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', [auth()->user()]);
 | 
			
		||||
                }
 | 
			
		||||
                if (!isset($arguments[0]) && !$app->auth->check()) {
 | 
			
		||||
                    throw new FireflyException('There is no user present.');
 | 
			
		||||
            ExportJobRepositoryInterface::class,
 | 
			
		||||
            function (Application $app) {
 | 
			
		||||
                /** @var ExportJobRepository $repository */
 | 
			
		||||
                $repository = app(ExportJobRepository::class);
 | 
			
		||||
                if ($app->auth->check()) {
 | 
			
		||||
                    $repository->setUser(auth()->user());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', $arguments);
 | 
			
		||||
                return $repository;
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user