Needs review
Project:
ConReg
Version:
1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
11 Feb 2026 at 02:38 UTC
Updated:
31 Mar 2026 at 12:31 UTC
Jump to comment: Most recent
The AddonStorage class uses static functions to make database calls against the "conreg_member_addons" table. It makes extensive use of \Drupal calls, which is a pattern that is discouraged.
N/A
The class should be converted to a service using dependency injection to access dependencies, and allowing it to be injected as a dependency to other classes.
The class should be moved into the src/Service directory.
src/Service.\Drupal::service(AddonStorage::class)-> will be needed.None.
None.
None.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lostcarpark commentedComment #3
ojchris commentedI'll work this.
Comment #4
ojchris commentedMade the conversion and aslo converted the Addon class but maintained addons in src folder cause several classes using the namespace. Left the functions
getAddon, markPaid, getMemberAddons, saveAddonsstatic cause of callers from other classes.Comment #6
ojchris commentedRaised MR. I've got doubts about making Addons class a service but did any way. @lostcarpark let if you want to keep it a utility as it was.
Comment #7
lostcarpark commentedHi @ojchris,
Nice work overall.
There are some coding standards issues that need looking at.
I think converting Addons class to a service is a good idea, but if you want to do that, you should fully convert it, and not have static calls to functions in the service. This would require finding all calls to the class and converting to service calls - there shouldn't be too many of those.
If you prefer to keep Addons as a static class, and have a follow up issue to convert to a service, I'm okay with that.
Comment #8
lostcarpark commentedComment #9
ojchris commented- Revert Addons class to utility
- Apply drupal standards to addons class and AddonStorage service
- Update AddonStorage constructor to use property promotion
- Set services _defaults, remove repeated autowire: true setting