Commit | Line | Data |
---|---|---|
1cc5f393 TO |
1 | <?php |
2 | /** | |
3 | * @file | |
4 | * | |
5 | * Perform an initial, partial bootstrap. | |
6 | * | |
7 | * GOAL: This should provide sufficient services for `InstallSchema` to generate | |
255d61a3 | 8 | * For example, `ts()` needs to be online. |
1cc5f393 TO |
9 | * |
10 | * MECHANICS: This basically loads `civicrm.settings.php` and calls | |
11 | * `CRM_Core_Config::singleton(FALSE,TRUE)`. | |
12 | */ | |
13 | ||
14 | if (!defined('CIVI_SETUP')) { | |
15 | exit("Installation plugins must only be loaded by the installer.\n"); | |
16 | } | |
17 | ||
18 | \Civi\Setup::dispatcher() | |
19 | ->addListener('civi.setup.checkRequirements', function (\Civi\Setup\Event\CheckRequirementsEvent $e) { | |
20 | ||
21 | }); | |
22 | ||
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__))); | |
26 | ||
27 | if (!defined('CIVICRM_SETTINGS_PATH')) { | |
28 | define('CIVICRM_SETTINGS_PATH', $e->getModel()->settingsPath); | |
29 | } | |
30 | ||
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)); | |
33 | } | |
34 | ||
35 | include_once CIVICRM_SETTINGS_PATH; | |
36 | ||
37 | require_once 'CRM/Core/ClassLoader.php'; | |
38 | CRM_Core_ClassLoader::singleton()->register(); | |
39 | ||
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); | |
43 | }; | |
44 | ||
45 | \Civi::$statics['testPreInstall'] = 1; | |
46 | ||
47 | CRM_Core_Config::singleton(FALSE, TRUE); | |
48 | ||
49 | }, \Civi\Setup::PRIORITY_PREPARE); |