Skip to content
Snippets Groups Projects
Commit 8952e1dd authored by totten's avatar totten
Browse files

api/changes - Clean up formatting under "4.7.0: Global $civicrm_setting: Multiple changes"

This section documents two distinct changes, but they had different
formatting -- which made it seem that (perhaps) the one code-block was
describing both changes.

This change uses similar formatting for both examples and changes the
indentation/alignment to indicate that they're distinct.
parent 52cd8ace
Branches
No related tags found
No related merge requests found
......@@ -543,35 +543,37 @@ See also: [CRM-16373](https://issues.civicrm.org/jira/browse/CRM-16373)
The global variable `$civicrm_setting` is used to [override CiviCRM settings](https://wiki.civicrm.org/confluence/display/CRMDOC/Override+CiviCRM+Settings). It has been changed:
- In previous versions, settings were indexed by group name (e.g. `Search Preferences`). In v4.7+, settings should be indexed by entity name ("domain" or "contact"). For backward compatibility, most group names are treated as an alias for "domain" or "contact".
- Old/Deprecated: `$civicrm_setting['Search Preferences']['search_autocomplete_count'] = 10;`
- New/Preferred: `$civicrm_setting['domain']['search_autocomplete_count'] = 10;`
- `$civicrm_setting` is usually modified within the file `civicrm.settings.php`, but it can be modified at runtime (e.g. in a hook). *If you modify it at runtime*, then you must also call `useMandatory()` to assimilate the changes. Examples for v4.6 and v4.7 are compared below.
**Override setting at runtime**
```php
// Ex: Compatible with v4.6 or older (minimalist)
function example_hook() {
global $civicrm_setting;
```php
// Old/Deprecated/Verbose. Compatible with v4.1+.
$civicrm_setting['Search Preferences']['search_autocomplete_count'] = 10;
}
// Ex: Compatible with v4.7 or newer (minimalist)
function example_hook() {
global $civicrm_setting;
// New/Preferred/Simplified. Compatible with v4.7+.
$civicrm_setting['domain']['search_autocomplete_count'] = 10;
Civi::service('settings_manager')->useMandatory();
}
// Ex: Compatible with both v4.6 and v4.7
function example_hook() {
global $civicrm_setting;
$civicrm_setting['Search Preferences']['search_autocomplete_count'] = 10;
if (version_compare('>=', CRM_Utils_System::version(), '4.7.alpha1')) {
Civi::service('settings_manager')->useMandatory();
}
}
```
```
- `$civicrm_setting` is usually modified within the file `civicrm.settings.php`, but it can be modified at runtime (e.g. in a hook). *If you modify it at runtime*, then you must also call `useMandatory()` to assimilate the changes. Examples for v4.6 and v4.7 are compared below.
```php
// Ex: Compatible with v4.6 or older (minimalist)
function example_hook() {
global $civicrm_setting;
$civicrm_setting['Search Preferences']['search_autocomplete_count'] = 10;
}
// Ex: Compatible with v4.7 or newer (minimalist)
function example_hook() {
global $civicrm_setting;
$civicrm_setting['domain']['search_autocomplete_count'] = 10;
Civi::service('settings_manager')->useMandatory();
}
// Ex: Compatible with both v4.6 and v4.7
function example_hook() {
global $civicrm_setting;
$civicrm_setting['Search Preferences']['search_autocomplete_count'] = 10;
if (version_compare('>=', CRM_Utils_System::version(), '4.7.alpha1')) {
Civi::service('settings_manager')->useMandatory();
}
}
```
See also: [CRM-16373](htps://issues.civicrm.org/jira/browse/CRM-16373).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment