-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
CRM-20923 refactor tpl to be based on metadata not hard-coding #10704
Conversation
eileenmcnaughton
commented
Jul 20, 2017
•
edited by civicrm-builder
Loading
edited by civicrm-builder
- CRM-20923: Refactor tpl for admin mail so it respects metadata
32bb8e4
to
8079d54
Compare
CRM/Admin/Form/Setting.php
Outdated
@@ -78,10 +78,11 @@ public function setDefaultValues() { | |||
* Build the form object. | |||
*/ | |||
public function buildQuickForm() { | |||
$session = CRM_Core_Session::singleton(); | |||
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); | |||
|
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.
no need for this space
CRM/Admin/Form/Setting.php
Outdated
$args = func_get_args(); | ||
$check = reset($args); | ||
// does this do anything? | ||
reset($args); |
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.
// does this do anything?
no it doesn't , $args function is not used at all so lines from 83 to 85 can be safely removed .
CRM/Admin/Form/Setting.php
Outdated
foreach ($this->_settings as $setting => $group) { | ||
$settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting)); | ||
$props = $settingMetaData['values'][$setting]; | ||
// Getting all once seems better than multiple calls. |
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.
this comment doesn't make sense for someone reading the code without looking at the commit history ... the code comments should describe the current version of the code not how it was before and how it get changed... this comment should be removed or replaced with something related .. but I prefer removing it.
CRM/Admin/Form/Setting.php
Outdated
$settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting)); | ||
$props = $settingMetaData['values'][$setting]; | ||
// Getting all once seems better than multiple calls. | ||
$allSettingMetaData = civicrm_api3('setting', 'getfields', array()); |
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.
probably better for this to move to seperate method :
```php
$settingMetaData = $this->getSettingsMetaData();
```php
/**
* Docblock goes here
*/
private function getSettingsMetaData() {
$allSettingsMetaData = civicrm_api3('setting', 'getfields', array());
$settingMetaData = array_intersect_key($allSettingMetaData['values'], $this->_settings);
// re-ordering the settings to follow $this->_settings order.
$settingMetaData = array_merge($this->_settings, $settingMetaData);
return $settingMetaData ;
}
CRM/Admin/Form/Setting.php
Outdated
$settingMetaData = array_intersect_key($allSettingMetaData['values'], $this->_settings); | ||
// This array_merge re-orders to the key order of $this->_settings. | ||
$settingMetaData = array_merge($this->_settings, $settingMetaData); | ||
|
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.
better to remove the space since the variables above used in the loop so it make more sense for them to be right before the loop , whole thing would be :
$descriptions = array();
$settingMetaData = $this->getSettingsMetaData();
foreach ($settingMetaData as $setting => $props) {
//etc
CRM/Admin/Form/Setting.php
Outdated
// This array_merge re-orders to the key order of $this->_settings. | ||
$settingMetaData = array_merge($this->_settings, $settingMetaData); | ||
|
||
foreach ($settingMetaData as $setting => $props) { |
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.
actually would be nicer (I think( if you moved the whole loop to another separate private method such buildingSettingFields($settingMetaData) or something like that .. it would make the could much easier to understand
CRM/Admin/Form/Setting.php
Outdated
$this->assign('setting_descriptions', $descriptions); | ||
$this->assign('settings', $settingMetaData); |
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.
isn't settingFields would be more descriptive name instead of just settings ?
@eileenmcnaughton generally these modifications look fine to me , though left view notes about the code itself ... also can you provide more details in the PR description + ticket to make sure that anyone read it understand what it about without the need to look into the code . |
Change-Id: Iee2a7aa9fa93c5d20b95f3dbc45ec2f3cf7a216b
8079d54
to
089360b
Compare
I've made the changes you suggested with the exception of the second function extraction. My hesitation there is I really want to get the whole $descriptions array out of that loop & those adhoc rules & feel like extracting makes it easier to ignore those issues next pass through |
@colemanw -are you able to merge this? |
Hmm encountered some style issue.. working on it |
you mean the green tick doesn't mean it passed? |
@eileenmcnaughton there was extra |
Tested, working fine |
Thanks @monishdeb - clearly a mistake I made in the second round when I decided to move the code into a sharable tpl ! I thought I did check it but obviously not very well! |