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

DOCS Update configuration docs #268

Merged

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli marked this pull request as draft May 16, 2023 03:56
@GuySartorelli GuySartorelli force-pushed the pulls/5.0/cms5-configuration branch 2 times, most recently from 9ca1111 to b8fedaf Compare May 17, 2023 03:08
@GuySartorelli GuySartorelli marked this pull request as ready for review May 17, 2023 03:09
Note that while both objects have similar methods the APIs differ slightly. The below actions are equivalent:
If you do need to modify configuration at run time, you can do so using the following API:

* `Config::modify()->merge(MyClass::class, 'property', 'newvalue');` or `MyClass::config()->merge('property', 'newvalue')` - merges the new configuration value in with any pre-existing values for this property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be including both ways of doing them when they're equivalent.

While it's OK to mention at the start there are 2x different way so to do it, MyClass::config()->merge('property', 'newvalue') is probably the better of the two since it's shorter, and reinforce s the fact you need to have the Configurable trait applied to the class in order for config to work.

Therefore could you please remove any references to Config::modify()->merge(MyClass::class, 'property', 'newvalue'); style setting here and in the rest of this doc

Copy link
Member Author

@GuySartorelli GuySartorelli May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This goes into "best practices" which will be covered in #269 later on. For now, both of these are valid ways to access the config and both work just fine. The scope of this PR and the issue it relates to is primarily "are the docs factually correct?"

Given that these examples already existed and I've just moved them and clarified them slightly, this suggestion goes out of scope for this PR.

See #212 regarding scope.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, config does work for classes that don't have the Configurable trait. It's recommended to have that trait, but it's not a requirement.

@emteknetnz emteknetnz merged commit 1c6adfc into silverstripe:5.0 May 18, 2023
@emteknetnz emteknetnz deleted the pulls/5.0/cms5-configuration branch May 18, 2023 23:52
Cambis added a commit to Cambis/silverstripe-phpstan that referenced this pull request Sep 16, 2024
- This was removed because the 'config' annotation is no longer recommended by Silverstripe. The rule itself was extending a final class from phpstan:^1.12 upwards as well
- See: silverstripe/developer-docs#268
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