Hi All, I am working on porting this module to drupal 8

Thanks

CommentFileSizeAuthor
#1 registration_role.zip3.57 KByogen.prasad

Comments

yogen.prasad’s picture

Assigned: yogen.prasad » Unassigned
StatusFileSize
new3.57 KB

I have done with Drupal 8 Port of Registration Role, Please review the module

Thanks

pfournier’s picture

Thanks for the port; some comments:

  • In RegistrationRoleSettings.php, buildForm(), line 56: you do not have to copy the $roles into $options. You can just use $roles in the $form definition.
  • In registration_role.module, registration_role_form_user_register_submit(), line 25: I do not think you are doing the same thing as the D7 version. The D7 version makes sure the registration role is attributed to the user (keeping all other roles from the form), but the D8 version only assign the registration role(s) to the user (discarding what was in the form)

The YAML files seems correct; I do not really knows how all this works.

pfournier’s picture

Status: Active » Needs work
yogen.prasad’s picture

Thanks pfournier, for your comments.

i will work on the same and let you know .

yogen.prasad’s picture

Assigned: Unassigned » yogen.prasad
Daniel Schaefer’s picture

Hey yogen.prasad, is the version from #1 the latest or did you make more changes?

yogen.prasad’s picture

Hi Daniel,

yes #1 is the latest version, i am not able to work further on this.

As there are some issues to be fixed.

Thanks

yogen.prasad’s picture

@pfournier

Sorry , i was not able to work on the your feedback on version #1.

for feedback 1: In RegistrationRoleSettings.php, buildForm(), line 56: you do not have to copy the $roles into $options. You can just use $roles in the $form definition.

here the $roles is a complete Role object which cant be used directly as $options in $form definition. That is why is process the $role and get a simple array for $option.


Array
(
    [administrator] => Drupal\user\Entity\Role Object
        (
            [id:protected] => administrator
            [label:protected] => Administrator
            [weight:protected] => 2
            [permissions:protected] => Array
                (
                )

            [is_admin:protected] => 1
            [originalId:protected] => administrator
            [pluginConfigKey:protected] => 
            [status:protected] => 1
            [uuid:protected] => 2a6bcbaf-31c1-473e-b900-af46dccc72de
            [isSyncing:Drupal\Core\Config\Entity\ConfigEntityBase:private] => 
            [isUninstalling:Drupal\Core\Config\Entity\ConfigEntityBase:private] => 
            [langcode:protected] => en
            [third_party_settings:protected] => Array
                (
                )

            [_core:protected] => Array
                (
                    [default_config_hash] => Om6FEO7vZZMkPIbVvfxtdkWerQ2PvQM4sWUd6Q3ZnfI
                )

            [trustedData:protected] => 
            [entityTypeId:protected] => user_role
            [enforceIsNew:protected] => 
            [typedData:protected] => 
            [cacheContexts:protected] => Array
                (
                )

            [cacheTags:protected] => Array
                (
                )

            [cacheMaxAge:protected] => -1
            [_serviceIds:protected] => Array
                (
                )

            [dependencies:protected] => Array
                (
                )

        )

    [editor] => Drupal\user\Entity\Role Object
        (
            [id:protected] => editor
            [label:protected] => Editor
            [weight:protected] => 3
            [permissions:protected] => Array
                (
                )

            [is_admin:protected] => 
            [originalId:protected] => editor
            [pluginConfigKey:protected] => 
            [status:protected] => 1
            [uuid:protected] => dc4507cd-da47-42c0-a319-25cb43888b3a
            [isSyncing:Drupal\Core\Config\Entity\ConfigEntityBase:private] => 
            [isUninstalling:Drupal\Core\Config\Entity\ConfigEntityBase:private] => 
            [langcode:protected] => en
            [third_party_settings:protected] => Array
                (
                )

            [_core:protected] => Array
                (
                )

            [trustedData:protected] => 
            [entityTypeId:protected] => user_role
            [enforceIsNew:protected] => 
            [typedData:protected] => 
            [cacheContexts:protected] => Array
                (
                )

            [cacheTags:protected] => Array
                (
                )

            [cacheMaxAge:protected] => -1
            [_serviceIds:protected] => Array
                (
                )

            [dependencies:protected] => Array
                (
                )

        )

)

for the 2nd feedback , i am looking for doing it at same as in D-7

Thanks

pfournier’s picture

here the $roles is a complete Role object which cant be used directly as $options in $form definition. That is why is process the $role and get a simple array for $option.

Ok; then this would be more user friendly:

foreach ($roles as $key => $value) {
      $options[$key] = $value->label();
}
yogen.prasad’s picture

Thanks pfournier,

I had made changes in code accordingly.

mlncn’s picture

Thanks Yogen! Could you make a Drupal 8 branch? I've given you commit access to this project, but please use it only for a Drupal 8 branch. This seems more reasonable than trying to create a patch for a new branch; i'm not sure how this is supposed to work. If you can't create a branch, please upload your most recent version. Thanks.

yogen.prasad’s picture

@mlcn

Thanks for GIT access . I will create a separate branch for Drupal 8 and commit updated code to Drupal 8 Branch.

yogen.prasad’s picture

@mlcn ,

I have created separate branch for D8 , and commit the code .

Thanks

karthikeyan-manivasagam’s picture

Hi @yogen and @mlcn,

Please commit the code I have working version of drupal 8 patch https://www.drupal.org/node/2817771

karthikeyan-manivasagam’s picture

karthikeyan-manivasagam’s picture

Status: Needs work » Needs review
mlncn’s picture

Version: 7.x-1.0 » 8.x-1.0-alpha1
Status: Needs review » Fixed

Yes, it is ported with an alpha release. Thanks!!!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.