Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve Registrars #9445

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

neznaika0
Copy link
Contributor

@neznaika0 neznaika0 commented Feb 7, 2025

Description
See #9231

  • Added getting the current config properties in Registrar
  • The behavior is configured in Modules

Now you can add, replace, and recursively replace arrays yourself. In Registrar (with the option enabled), apply any changes based on the input data. The name of the argument is not important as long as we trust the user.

This is a draft stage, if you approve it, I will supplement the documentation and corrections.

The develop branch because it doesn't break existing code until the option is enabled.

I noticed that there is no mention of the configuration rewriting order anywhere. The first modules in the A-Z order can be overwritten.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@neznaika0 neznaika0 force-pushed the feat/improve-registrars branch from f70d2d8 to 5421889 Compare February 7, 2025 22:55
@michalsn
Copy link
Member

michalsn commented Feb 8, 2025

Sorry, but this doesn't make sense to me.

In the proposed implementation, the most recently loaded module wins and overwrites the values previously set by other modules.

@michalsn
Copy link
Member

michalsn commented Feb 8, 2025

New features won't be accepted in the develop branch.

@neznaika0
Copy link
Contributor Author

This does not apply to PR - a simple reminder. In general, can the argument with $this be accepted?

@michalsn
Copy link
Member

michalsn commented Feb 9, 2025

Well, it would have been nice if you had mentioned that currently, only tests are working.

So the changes that will take place can be boiled down to the fact that instead of array_merge(), we will use array_replace_recursive()? Are you planning anything else?

IMO if you want to replace anything that is an array, you should rather modify the base config file and not try to use Registrars. What you’re planning should work for associative arrays, but will fail miserably for indexed arrays.

From my perspective, this function is not desirable - mainly because it will cause more problems than good. And more "shortcomings" will only multiply - because I can think of a few.

The solution would be to encapsulate this in some kind of manager, but... Registrars were invented with very simple operations in mind, and they should stay that way.

For my part, I have already expressed my opinion on the subject. If you find someone who supports this idea - go ahead.

@neznaika0
Copy link
Contributor Author

No. It is not necessary to use array_* inside. This gives the flexibility for the user to change the values as he wants.

If you're worried about problems, then what do you say that anyone can replace with any value instead of the original type string => int ? You can say it's a bug. Otherwise, flexibility. This does not negate the fact that the array can still be broken without this PR (example, in Filters ['before' => ...].

In addition, it is a configurable option.

If things are that bad, CI doesn't have a good way to work with configs. They all depend heavily on app/Config/*. The user always needs to manually add changes for each package. It seems that this is all it is designed for.

@paulbalandan @kenjis @MGatner @samsonasik Share your opinion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants