* Class constructor.
*/
public function __construct() {
- $paths = $this;
+ // Below is a *default* set of functions to calculate paths/URLs.
+ // Some variables may be overridden as follow:
+ // - The global `$civicrm_paths` may be preset before Civi boots. (Ex: via `civicrm.settings.php`, `settings.php`, or `vendor/autoload.php`)
+ // - Variables may be re-registered. (Ex: via `CRM_Utils_System_WordPress`)
$this
->register('civicrm.root', function () {
return \CRM_Core_Config::singleton()->userSystem->getCiviSourceStorage();
->register('civicrm.packages', function () {
return [
'path' => \Civi::paths()->getPath('[civicrm.root]/packages/'),
- 'url' => \Civi::paths()->getUrl('[civicrm.root]/packages/'),
+ 'url' => \Civi::paths()->getUrl('[civicrm.root]/packages/', 'absolute'),
];
})
->register('civicrm.vendor', function () {
return [
'path' => \Civi::paths()->getPath('[civicrm.root]/vendor/'),
- 'url' => \Civi::paths()->getUrl('[civicrm.root]/vendor/'),
+ 'url' => \Civi::paths()->getUrl('[civicrm.root]/vendor/', 'absolute'),
];
})
->register('civicrm.bower', function () {
return [
'path' => \Civi::paths()->getPath('[civicrm.root]/bower_components/'),
- 'url' => \Civi::paths()->getUrl('[civicrm.root]/bower_components/'),
+ 'url' => \Civi::paths()->getUrl('[civicrm.root]/bower_components/', 'absolute'),
];
})
->register('civicrm.files', function () {
'path' => is_dir($dir) ? $dir : \Civi::paths()->getPath('[civicrm.root]/l10n'),
];
})
- ->register('wp.frontend.base', function () {
- return ['url' => rtrim(CIVICRM_UF_BASEURL, '/') . '/'];
- })
- ->register('wp.frontend', function () use ($paths) {
- $config = \CRM_Core_Config::singleton();
- $suffix = defined('CIVICRM_UF_WP_BASEPAGE') ? CIVICRM_UF_WP_BASEPAGE : $config->wpBasePage;
- return [
- 'url' => $paths->getVariable('wp.frontend.base', 'url') . $suffix,
- ];
- })
- ->register('wp.backend.base', function () {
- return ['url' => rtrim(CIVICRM_UF_BASEURL, '/') . '/wp-admin/'];
- })
- ->register('wp.backend', function () use ($paths) {
- return [
- 'url' => $paths->getVariable('wp.backend.base', 'url') . 'admin.php',
- ];
- })
->register('cms', function () {
return [
'path' => \CRM_Core_Config::singleton()->userSystem->cmsRootPath(),