5 * Perform an initial, partial bootstrap.
7 * GOAL: This should provide sufficient services for `InstallSchema` to generate
8 * For example, `ts()` needs to be online.
10 * MECHANICS: This basically loads `civicrm.settings.php` and calls
11 * `CRM_Core_Config::singleton(FALSE,TRUE)`.
14 if (!defined('CIVI_SETUP')) {
15 exit("Installation plugins must only be loaded by the installer.\n");
18 \Civi\Setup
::dispatcher()
19 ->addListener('civi.setup.checkRequirements', function (\Civi\Setup\Event\CheckRequirementsEvent
$e) {
23 \Civi\Setup
::dispatcher()
24 ->addListener('civi.setup.installDatabase', function (\Civi\Setup\Event\InstallDatabaseEvent
$e) {
25 \Civi\Setup
::log()->info(sprintf('[%s] Load minimal (non-DB) services', basename(__FILE__
)));
27 if (!defined('CIVICRM_SETTINGS_PATH')) {
28 define('CIVICRM_SETTINGS_PATH', $e->getModel()->settingsPath
);
31 if (realpath(CIVICRM_SETTINGS_PATH
) !== realpath($e->getModel()->settingsPath
)) {
32 throw new \
RuntimeException(sprintf("Cannot boot: The civicrm.settings.php path appears inconsistent (%s vs %s)", CIVICRM_SETTINGS_PATH
, $e->getModel()->settingsPath
));
35 include_once CIVICRM_SETTINGS_PATH
;
37 require_once 'CRM/Core/ClassLoader.php';
38 CRM_Core_ClassLoader
::singleton()->register();
40 $conn = \Civi\Setup\DbUtil
::connect($e->getModel()->db
);
41 \CRM_Core_I18n
::$SQL_ESCAPER = function($text) use ($conn) {
42 return $conn->escape_string($text);
45 \Civi
::$statics['testPreInstall'] = 1;
47 CRM_Core_Config
::singleton(FALSE, TRUE);
49 }, \Civi\Setup
::PRIORITY_PREPARE
);