}
/**
- * Bootstrap the non-existent CMS
+ * Bootstrap composer libs.
+ *
+ * This is used by cv and civix, but not I (artfulrobot) think, in the main http requests.
*
* @param array $params
* Either uid, or name & pass.
* @Todo Handle setting cleanurls configuration for CiviCRM?
*/
public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
- static $run_once = FALSE;
- if ($run_once) {
+ static $runOnce;
+ if (!isset($runOnce)) {
+ $runOnce = TRUE;
return TRUE;
}
- else {
- $run_once = TRUE;
+
+ if (!($root = $this->cmsRootPath())) {
+ // What does this guard against?
+ return FALSE;
+ }
+ chdir($root);
+
+ // Create a mock $request object
+ require_once $root . '../vendor/autoload.php'; /* assumes $root to be the _web_ root path, not the project root path. */
+
+ if ($loadUser) {
+ // @todo
+ // if (!empty($params['uid']) && ...) {
+ // $this->loadUser($username);
+ // }
+ // elseif (!empty($params['name']) && !empty($params['pass']) && ...can authenticate...) {
+ // $this->loadUser($params['name']);
+ // }
}
- // @todo ?
return TRUE;
}
if (!empty($civicrm_paths['cms.root']['path'])) {
return $civicrm_paths['cms.root']['path'];
}
-
- // @todo?
- throw new \RuntimeException("Standalone requires that you set \$civicrm_paths['cms.root']['path'] in civicrm.settings.php");
+ throw new \RuntimeException("Standalone requires the path is set for now. Set \$civicrm_paths['cms.root']['path'] in civicrm.settings.php to the webroot.");
}
/**
}
\Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'init'));
+ // NOTE: in here, $model->webroot refers to the root of the *application*, not the actual webroot as reachable by http.
+ // Typically this means that $model->webroot might be like /var/www/example.org/ and the actual web root would be
+ // /var/www/example.org/web/
+
// Compute settingsPath.
// We use this structure: /var/www/standalone/data/{civicrm.settings.php,templates_c}
// to reduce the number of directories that admins have to chmod
// Compute DSN.
$model->db = $model->cmsDb = [
- 'server' => 'localhost',
- 'username' => '',
- 'password' => '',
- 'database' => '',
+ 'server' => 'mysql',
+ 'username' => 'loner',
+ 'password' => 'somepass',
+ 'database' => 'standalone_civicrm',
];
// Compute URLs (@todo?)