firefly-iii/app/Providers/ExportJobServiceProvider.php

87 lines
2.2 KiB
PHP
Raw Normal View History

2016-03-03 01:53:05 -06:00
<?php
/**
* ExportJobServiceProvider.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
2016-05-20 01:57:45 -05:00
declare(strict_types = 1);
2016-03-03 01:53:05 -06:00
namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
/**
* Class ExportJobServiceProvider
*
* @package FireflyIII\Providers
*/
class ExportJobServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
2016-06-10 14:00:00 -05:00
$this->exportJob();
$this->importJob();
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
/**
*
*/
private function exportJob()
{
2016-03-03 01:53:05 -06:00
$this->app->bind(
'FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface',
function (Application $app, array $arguments) {
2016-04-27 03:38:51 -05:00
if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', [$app->auth->user()]);
2016-04-27 22:50:29 -05:00
}
if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.');
2016-03-03 01:53:05 -06:00
}
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', $arguments);
}
);
}
2016-06-10 14:00:00 -05:00
private function importJob()
2016-03-03 01:53:05 -06:00
{
2016-06-10 14:00:00 -05:00
$this->app->bind(
'FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface',
function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Repositories\ImportJob\ImportJobRepository', [$app->auth->user()]);
}
if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.');
}
return app('FireflyIII\Repositories\ImportJob\ImportJobRepository', $arguments);
}
);
2016-03-03 01:53:05 -06:00
}
}