Added a new argument to the constructor of the account repository which should correctly inject the user.

This commit is contained in:
James Cole
2016-03-03 08:31:18 +01:00
parent fcf16051a2
commit 8008311d9c
5 changed files with 136 additions and 65 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace FireflyIII\Providers;
use Auth;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
/**
* Class AccountServiceProvider
*
* @package FireflyIII\Providers
*/
class AccountServiceProvider 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\Account\AccountRepositoryInterface',
function (Application $app, array $arguments) {
if (!isset($arguments[0]) && Auth::check()) {
return app('FireflyIII\Repositories\Account\AccountRepository', [Auth::user()]);
} else {
if (!isset($arguments[0]) && !Auth::check()) {
throw new FireflyException('There is no user present.');
}
}
return app('FireflyIII\Repositories\Account\AccountRepository', $arguments);
}
);
}
}