Skip to content

Instantly share code, notes, and snippets.

@totten
Last active June 22, 2017 21:21
Show Gist options
  • Save totten/3fa698d88bb6a52f49df62a3ffcdf034 to your computer and use it in GitHub Desktop.
Save totten/3fa698d88bb6a52f49df62a3ffcdf034 to your computer and use it in GitHub Desktop.
<?php
global $civicrm_paths;
$civicrm_paths['cms.root']['path'] = '/var/www/example.com';
$civicrm_paths['cms.root']['url'] = 'http://example.com';
$civicrm_paths['civicrm.root']['*'] = '[cms.root]/sites/all/modules/civicrm';
$civicrm_paths['civicrm.files']['*'] = '[cms.root]/sites/default/files/civicrm';
$civicrm_paths['civicrm.private']['*'] = '[cms.root]/sites/default/private/civicrm';
$civicrm_paths['civicrm.log']['*'] = '[civicrm.private]/configAndLogDir';
$civicrm_paths['civicrm.imageUpload']['*'] = '[civicrm.files]/persist/contribute';
$civicrm_paths['civicrm.phpCache']['*'] = '[civicrm.private]/templates_c';
$civicrm_paths['civicrm.assetCache']['*'] = '[civicrm.files]/dyn';
$civicrm_paths['civicrm.ckeditor']['*'] = '[civicrm.files]/ckeditor';
$civicrm_paths['civicrm.extension']['*'] = '[civicrm.files]/ext';
$civicrm_paths['civicrm.packages']['*'] = '[civicrm.root]/packages';
// Note: Each item in `$civicrm_paths` can specify any of these keys:
// '*' default formula
// 'path' local file path. (if omitted, use '*')
// 'url' url (if omitted, use '*')
// Note: By default, everything is derived from `cms.root`.
// Another reasonable policy would be make everything concrete.
// It's really up to the installer.
// Note: Huzzah, in the average case, we don't have duplicate values
// like `imageUploadDir` and `imageUploadURL`.
<?php
global $civicrm_paths;
$civicrm_paths['cms.root']['path'] = '/var/www/example.com';
$civicrm_paths['cms.root']['url'] = 'http://example.com';
$civicrm_paths['cms.admin']['url'] = '[cms.root]/wp-admin';
$civicrm_paths['civicrm.root']['*'] = '[cms.root]/wp-content/plugins/civicrm/civicrm';
$civicrm_paths['civicrm.files']['*'] = '[cms.root]/uploads/civicrm';
$civicrm_paths['civicrm.private']['*'] = '[cms.root]/uploads/_civicrm';
$civicrm_paths['civicrm.log']['*'] = '[civicrm.private]/configAndLogDir';
$civicrm_paths['civicrm.imageUpload']['*'] = '[civicrm.files]/persist/contribute';
$civicrm_paths['civicrm.phpCache']['*'] = '[civicrm.private]/templates_c';
$civicrm_paths['civicrm.assetCache']['*'] = '[civicrm.files]/dyn';
$civicrm_paths['civicrm.ckeditor']['*'] = '[civicrm.files]/ckeditor';
$civicrm_paths['civicrm.extension']['*'] = '[civicrm.files]/ext';
$civicrm_paths['civicrm.packages']['*'] = '[civicrm.root]/packages';
// Note: each item in `$civicrm_paths` can specify any of these keys:
// '*' default formula
// 'path' local file path. (if omitted, use '*')
// 'url' url (if omitted, use '*')
// Note: by default, everything is derived from `cms.root`.
// Another reasonable policy would be make everything concrete.
// It's really up to the installer.
<?php
Civi::paths()->getPath('[civicrm.log]');
Civi::paths()->getPath('[civicrm.imageUpload]/foo.jpg');
Civi::paths()->getUrl('[civicrm.imageUpload]/foo.jpg');
Civi::paths()->getPath('[civicrm.ckeditor]');
Civi::paths()->getUrl('[civicrm.ckeditor]');
<?php
// To facilitate transition, CRM_Core_Config::singleton()->configAndLogDir should look
// in both `Civi::paths()` and the traditional location. For example, to __get('configAndLogDir'):
if (Civi::paths()->hasVariable('[civicrm.log]')) {
$value = Civi::paths()->getPath('[civicrm.log]');
} else {
$value = oldLogic();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment