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
Setting Admin - Add mixin to autogenerate a settings form #27569
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
4cd5efe
to
a2c0e6d
Compare
@totten yep - looks good! |
So the path is always the extension key? Sounds reasonable just not clear from description. I'm so used to "wiring" up extension settings pages I hardly think about it but it's a lot of steps and this looks really nice + simplifies extension + makes a transition to a non-quickform settings page easy in the future (ie. just replace the mixin). |
Yeah, I had done the path with the |
71a45fe
to
62c9710
Compare
62c9710
to
e8da17a
Compare
OK, multiple updates:
|
* @return string|null | ||
* Return NULL by default. If the walk was short-circuited, then return that value. | ||
*/ | ||
public static function walk(&$items, callable $callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this like run but slower?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rofl. Yeah, basically.
FWIW, for an example of this wording, see https://www.php.net/array_walk or https://www.php.net/array_walk_recursive. It's the same basic idea, except that it's tuned to the properties used by nav-menu (e.g. $item
, $item['child']
, $item['attribute']
).
Is there a docs MR for this? The relevant docs page looks to be Creating a extension setting and admin form and text could be borrowed from the code doc |
Overview
@mattwire @eileenmcnaughton @seamuslee001 - I was reading https://docs.civicrm.org/dev/en/latest/framework/setting/extension/, and it struck me that many of these steps could be done automatically...
Before
Suppose you are creating extension
foobar
. It needs some settings and a setting page. Process:civix generate:module foobar
)nano settings/foobar.setting.php
)hook_civicrm_permission
and declareadminister foobar
xml/Menu/foobar.xml
and define routecivicrm/admin/setting/foobar
. Enable mixinmenu-xml@1
.settings_page => ['foobar' => ['weight' => 123]]
(with differing values of 123)(And, of course, clear caches.)
After
The last several steps are consolidated into one step. Process:
civix generate:module foobar
)nano settings/foobar.setting.php
)info.xml
, add<mixin>setting-admin@1</mixin>
.(And, of course, clear caches.)
Comments
Example extension: https://lab.civicrm.org/-/snippets/95
This mixin should be amenable to backporting. So we could add it to
civix
and use it for extensions that run on older versions ofcivicrm-core
. I don't know how far back compatibility would go... but probably several years. For DX, the process would be like:If the concept seems good, then we should add some tests to the mixin.