mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
New attachment service provider.
This commit is contained in:
49
app/Providers/AttachmentServiceProvider.php
Normal file
49
app/Providers/AttachmentServiceProvider.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Providers;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Class AttachmentServiceProvider
|
||||
*
|
||||
* @package FireflyIII\Providers
|
||||
*/
|
||||
class AttachmentServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind(
|
||||
'FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface',
|
||||
function (Application $app, array $arguments) {
|
||||
if (!isset($arguments[0]) && Auth::check()) {
|
||||
return app('FireflyIII\Repositories\Attachment\AttachmentRepository', [Auth::user()]);
|
||||
} else {
|
||||
if (!isset($arguments[0]) && !Auth::check()) {
|
||||
throw new FireflyException('There is no user present.');
|
||||
}
|
||||
}
|
||||
|
||||
return app('FireflyIII\Repositories\Attachment\AttachmentRepository', $arguments);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user