You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The registerRepositoryInterfaces() function in DefenderServiceProvider class is creating the Role and Permission singletons based on default package classes. This does not allows the repository pattern to provide expected behavior.
I'm using MongoDB and need to extend my models from a different class than default Eloquent\Model. Below are the key parts of this logic:
protected function registerRepositoryInterfaces()
{
$this->app->singleton('defender.role', function ($app) {
return new EloquentRoleRepository($app, new Role());
});
...
$this->app->singleton('defender.permission', function ($app) {
return new EloquentPermissionRepository($app, new Permission());
});
...
$this->app->singleton('defender.user', function ($app) {
$userModel = $app['config']->get('defender.user_model');
return new EloquentUserRepository($app, $app->make($userModel));
});
...
}
The $userModel creation follows the correct behavior, so should be the Role and Permission, but changing the logic throws the error:
Type error: Argument 2 passed to Artesaos\Defender\Repositories\Eloquent\EloquentRoleRepository::__construct() must be an instance of Artesaos\Defender\Role
So, I believe one strategy would be to refactor the Role and Permission classes into traits to be used by necessary classes of the app or by default flat classes of the package. This, of course, needs to be better studied. Or a simpler aproach by changing the signature of the __construct functions of EloquentRoleRepository and EloquentPermissionRepository classes.
The text was updated successfully, but these errors were encountered:
nunomazer
changed the title
Role and Permissions should be created based on config file
Role and Permission should be created based on config file
May 28, 2016
The
registerRepositoryInterfaces()
function inDefenderServiceProvider
class is creating theRole
andPermission
singletons based on default package classes. This does not allows the repository pattern to provide expected behavior.I'm using MongoDB and need to extend my models from a different class than default
Eloquent\Model
. Below are the key parts of this logic:The
$userModel
creation follows the correct behavior, so should be theRole
andPermission
, but changing the logic throws the error:So, I believe one strategy would be to refactor the
Role
andPermission
classes into traits to be used by necessary classes of the app or by default flat classes of the package. This, of course, needs to be better studied. Or a simpler aproach by changing the signature of the__construct
functions ofEloquentRoleRepository
andEloquentPermissionRepository
classes.The text was updated successfully, but these errors were encountered: