firefly-iii/app/Providers/CrudServiceProvider.php

65 lines
1.5 KiB
PHP
Raw Normal View History

<?php
/**
* CrudServiceProvider.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
/**
* Class CrudServiceProvider
*
* @package FireflyIII\Providers
*/
class CrudServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
2016-05-20 04:53:34 -05:00
$this->registerJournal();
}
2016-05-20 02:25:17 -05:00
2016-05-20 04:53:34 -05:00
private function registerJournal()
{
2016-05-20 02:25:17 -05:00
$this->app->bind(
2016-05-20 04:53:34 -05:00
'FireflyIII\Crud\Split\JournalInterface',
2016-05-20 02:25:17 -05:00
function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) {
2016-07-23 14:37:06 -05:00
return app('FireflyIII\Crud\Split\Journal', [auth()->user()]);
2016-05-20 02:25:17 -05:00
}
if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.');
}
2016-05-20 04:53:34 -05:00
return app('FireflyIII\Crud\Split\Journal', $arguments);
2016-05-20 02:25:17 -05:00
}
);
2016-05-20 04:53:34 -05:00
}
}