I have the following UserServiceProvider
and I'm wondering whether so much dependency injection is overkill:
use
Illuminate\Support\ServiceProvider,
App\Repositories\Eloquent\User\EloquentUserRepository,
App\Repositories\Eloquent\Profile\EloquentProfileRepository,
App\Repositories\Eloquent\Seller\EloquentSellerRepository,
App\Repositories\Eloquent\AppResponse\EloquentAppResponseRepository,
App\Repositories\Eloquent\AppRequest\EloquentAppRequestRepository,
App\Repositories\Eloquent\Model\EloquentModelRepository,
App\Repositories\Eloquent\Maker\EloquentMakerRepository,
Cartalyst\Sentry\Sentry,
App\Services\Cache\Decorators\UserCacheDecorator,
App\Services\Cache\Laravel\LaravelCache,
App\Entities\Entities\Profile\ProfileEntity,
App\Entities\Entities\Seller\SellerEntity,
App\Entities\Entities\AppRequest\AppRequestEntity,
App\Entities\Entities\AppResponse\AppResponseEntity,
App\Entities\Entities\Model\ModelEntity,
App\Entities\Entities\Maker\MakerEntity,
Profile,
Seller,
AppResponse,
AppRequest,
Model,
Maker;
class UserServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind('App\Repositories\Interfaces\UserRepositoryInterface', function($app)
{
$user = new EloquentUserRepository(
new Sentry(),
new ProfileEntity(
new EloquentProfileRepository(
new Profile()
)
),
new SellerEntity(
new EloquentSellerRepository(
new Seller()
)
),
new AppRequestEntity(
new EloquentAppRequestRepository(
new AppRequest()
)
),
new AppResponseEntity(
new EloquentAppResponseRepository(
new AppResponse()
)
),
new ModelEntity(
new EloquentModelRepository(
new Model()
)
),
new MakerEntity(
new EloquentMakerRepository(
new Maker()
)
)
);
return new UserCacheDecorator(
$user,
new LaravelCache($app['cache'], 'user')
);
});
}
}
I do need all these entities in my UserEntity
. Is this normal or should I start reducing the number of injections?