public function onBootstrap(MvcEvent $e)
    {
        if (!$e->getRequest() instanceof HttpRequest) {
            return;
        }

        $app = $e->getApplication();
        $services = $app->getServiceManager();

        $eventManager       = $app->getEventManager();
        $sharedEventManager = $eventManager->getSharedManager();

        $sharedEventManager->attach(UserService::class, 'register', function($e) use ($services)
        {
            $user = $e->getParam('user');
            if ($user instanceof RoleableInterface &&
                $services->has(AuthorizationModuleOptions::class)
            ) {
                /* @var $config PermissionsModuleOptions */
                $config = $services->get(PermissionsModuleOptions::class);
                $roleClass = $config->getRoleEntityClass();
                $mapper = $services->get('MapperManager')->get($roleClass);
                if ($defaultRole = $mapper->find($config->getAuthenticatedRole())) {
                    $user->addRole($defaultRole);
                }
            }
        }, 100);
    }
public function onBootstrap(MvcEvent $e)
    {
        if (!$e->getRequest() instanceof HttpRequest) {
            return;
        }

        $app = $e->getApplication();
        $services = $app->getServiceManager();

        $eventManager       = $app->getEventManager();
        $sharedEventManager = $eventManager->getSharedManager();

        $sharedEventManager->attach(UserService::class, 'register', function($e) use ($services)
        {
            $user = $e->getParam('user');
            if ($user instanceof RoleableInterface &&
                $services->has(AuthorizationModuleOptions::class)
            ) {
                /* @var $config PermissionsModuleOptions */
                $config = $services->get(PermissionsModuleOptions::class);
                $roleClass = $config->getRoleEntityClass();
                $mapper = $services->get('MapperManager')->get($roleClass);
                if ($defaultRole = $mapper->find($config->getAuthenticatedRole())) {
                    $user->addRole($defaultRole);
                }
            }
        }, 100);
    }
public function onBootstrap ( MvcEvent $ e ) { if ( ! $ e -> getRequest ( ) instanceof HttpRequest ) { return ; } $ app = $ e -> getApplication ( ) ; $ services = $ app -> getServiceManager ( ) ; $ eventManager = $ app -> getEventManager ( ) ; $ sharedEventManager = $ eventManager -> getSharedManager ( ) ; $ sharedEventManager -> attach ( UserService :: class , 'register' , function ( $ e ) use ( $ services ) { $ user = $ e -> getParam ( 'user' ) ; if ( $ user instanceof RoleableInterface && $ services -> has ( AuthorizationModuleOptions :: class ) ) { /* @var $config PermissionsModuleOptions */ $ config = $ services -> get ( PermissionsModuleOptions :: class ) ; $ roleClass = $ config -> getRoleEntityClass ( ) ; $ mapper = $ services -> get ( 'MapperManager' ) -> get ( $ roleClass ) ; if ( $ defaultRole = $ mapper -> find ( $ config -> getAuthenticatedRole ( ) ) ) { $ user -> addRole ( $ defaultRole ) ; } } } , 100 ) ; }
Event callback to be triggered on bootstrap

@param MvcEvent $e
@return void
Event callback to be triggered on bootstrap