Currently the email_registration module only contains procedural code.

Functions like email_registration_unique_username and email_registration_cleanup_username could be moved to a separate service.

The patch attached, moves these 2 functions to a separate service.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JeroenT created an issue. See original summary.

JeroenT’s picture

Re-uploading patch to run tests.

Status: Needs review » Needs work

The last submitted patch, 2: move_username_functions_to_OO.patch, failed testing.

JeroenT’s picture

Status: Needs work » Needs review
FileSize
9.81 KB
10.16 KB

Fixed coding standards + added email_registration.services.yml file.

Status: Needs review » Needs work

The last submitted patch, 4: move_username_functions-2831238-3.patch, failed testing.

JeroenT’s picture

Status: Needs review » Needs work

The last submitted patch, 6: move_username_functions-2831238-6.patch, failed testing.

JeroenT’s picture

Status: Needs work » Needs review
FileSize
7.3 KB
andypost’s picture

Idea looks good except name for service

+++ b/email_registration.services.yml
@@ -0,0 +1,4 @@
+  email_registration.username_helper:
+    class: Drupal\email_registration\UsernameHelper

helper really confusion and tells nothing about what this file for

JeroenT’s picture

Status: Needs review » Needs work
JeroenT’s picture

@andypost,

Any suggestion for the classname?

andypost’s picture

not yet( maybe better to split it more because clean-up can be a static class member
but this will just add more cpu usage for autoloading

So overall only db query could be in service but here's #551626: slow query in email_registration_user_login_validate

btw This conversion may have sense in terms of #657472: Add setting to allow users to login with email address or username but everything in hooks that means procedural...

So after thinking about it I'd better postponed that until #2402445: Implement object oriented form alters

andypost’s picture

Status: Needs work » Postponed

yep, let's postpone on OOP way for forms

andypost’s picture

Status: Postponed » Needs work
Related issues: +#3021912: Plan for creating email registration 8.x-1.0 final stable

As release 1.0 on a way, and we getting rid of legacy, it makes sense again

Grevil’s picture

Title: Move username functions to OO code » [2.x] Move username functions to OO code
Priority: Normal » Minor
Grevil’s picture

Version: 8.x-1.x-dev » 2.x-dev