/**
* Determine the location of the CiviCRM source tree.
*
- * FIXME:
- * 1. This was pulled out from a bigger function. It should be split
- * into even smaller pieces and marked abstract.
- * 2. This would be easier to compute by a calling a CMS API, but
- * for whatever reason we take the hard way.
- *
* @return array
* - url: string. ex: "http://example.com/sites/all/modules/civicrm"
* - path: string. ex: "/var/www/sites/all/modules/civicrm"
*/
- public function getCiviSourceStorage() {
- global $civicrm_root;
- $config = CRM_Core_Config::singleton();
-
- // Don't use $config->userFrameworkBaseURL; it has garbage on it.
- // More generally, w shouldn't be using $config here.
- if (!defined('CIVICRM_UF_BASEURL')) {
- throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
- }
- $baseURL = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/');
- if (CRM_Utils_System::isSSL()) {
- $baseURL = str_replace('http://', 'https://', $baseURL);
- }
-
- // @todo this function is only called / code is only reached when is_drupal is true - move this to the drupal classes
- // and don't implement here.
- if ($this->is_drupal) {
- // Drupal setting
- // check and see if we are installed in sites/all (for D5 and above)
- // we dont use checkURL since drupal generates an error page and throws
- // the system for a loop on lobo's macosx box
- // or in modules
- $cmsPath = $config->userSystem->cmsRootPath();
- $userFrameworkResourceURL = $baseURL . str_replace("$cmsPath/", '',
- str_replace('\\', '/', $civicrm_root)
- );
-
- $siteName = $config->userSystem->parseDrupalSiteNameFromRoot($civicrm_root);
- if ($siteName) {
- $civicrmDirName = trim(basename($civicrm_root));
- $userFrameworkResourceURL = $baseURL . "sites/$siteName/modules/$civicrmDirName/";
- }
- }
- else {
- $userFrameworkResourceURL = '';
- }
-
- return [
- 'url' => CRM_Utils_File::addTrailingSlash($userFrameworkResourceURL, '/'),
- 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root),
- ];
- }
+ abstract public function getCiviSourceStorage():array;
/**
* Perform any post login activities required by the CMS.
}
}
+ /**
+ * @inheritdoc
+ */
+ public function getCiviSourceStorage():array {
+ global $civicrm_root;
+ $config = CRM_Core_Config::singleton();
+
+ // Don't use $config->userFrameworkBaseURL; it has garbage on it.
+ // More generally, w shouldn't be using $config here.
+ if (!defined('CIVICRM_UF_BASEURL')) {
+ throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
+ }
+ $baseURL = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/');
+ if (CRM_Utils_System::isSSL()) {
+ $baseURL = str_replace('http://', 'https://', $baseURL);
+ }
+
+ // Check and see if we are installed in sites/all (for D5 and above).
+ // We dont use checkURL since drupal generates an error page and throws
+ // the system for a loop on lobo's macosx box
+ // or in modules.
+ $cmsPath = $config->userSystem->cmsRootPath();
+ $userFrameworkResourceURL = $baseURL . str_replace("$cmsPath/", '',
+ str_replace('\\', '/', $civicrm_root)
+ );
+
+ $siteName = $config->userSystem->parseDrupalSiteNameFromRoot($civicrm_root);
+ if ($siteName) {
+ $civicrmDirName = trim(basename($civicrm_root));
+ $userFrameworkResourceURL = $baseURL . "sites/$siteName/modules/$civicrmDirName/";
+ }
+
+ return [
+ 'url' => CRM_Utils_File::addTrailingSlash($userFrameworkResourceURL, '/'),
+ 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root),
+ ];
+ }
+
/**
* @inheritDoc
*/
* - url: string. ex: "http://example.com/sites/all/modules/civicrm"
* - path: string. ex: "/var/www/sites/all/modules/civicrm"
*/
- public function getCiviSourceStorage() {
+ public function getCiviSourceStorage():array {
global $civicrm_root;
if (!defined('CIVICRM_UF_BASEURL')) {
throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
throw new \RuntimeException("Not implemented");
}
+ /**
+ * @inheritdoc
+ */
+ public function getCiviSourceStorage():array {
+ global $civicrm_root;
+
+ if (!defined('CIVICRM_UF_BASEURL')) {
+ throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
+ }
+
+ return [
+ 'url' => CRM_Utils_File::addTrailingSlash('', '/'),
+ 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root),
+ ];
+ }
+
}
return TRUE;
}
+ /**
+ * @inheritdoc
+ */
+ public function getCiviSourceStorage(): array {
+ global $civicrm_root;
+
+ if (!defined('CIVICRM_UF_BASEURL')) {
+ throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
+ }
+
+ return [
+ 'url' => CRM_Utils_File::addTrailingSlash('', '/'),
+ 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root),
+ ];
+ }
+
/**
* Determine the location of the CMS root.
*
return TRUE;
}
+ /**
+ * @inheritdoc
+ */
+ public function getCiviSourceStorage(): array {
+ global $civicrm_root;
+
+ if (!defined('CIVICRM_UF_BASEURL')) {
+ throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
+ }
+
+ return [
+ 'url' => CRM_Utils_File::addTrailingSlash('', '/'),
+ 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root),
+ ];
+ }
+
/**
* @inheritDoc
*/
* - url: string. ex: "http://example.com/sites/all/modules/civicrm"
* - path: string. ex: "/var/www/sites/all/modules/civicrm"
*/
- public function getCiviSourceStorage() {
+ public function getCiviSourceStorage():array {
global $civicrm_root;
// Don't use $config->userFrameworkBaseURL; it has garbage on it.