diff --git a/plugins/installDatabase/InstallSchema.civi-setup.php b/plugins/installDatabase/InstallSchema.civi-setup.php index 3b1f015..6aae6c7 100644 --- a/plugins/installDatabase/InstallSchema.civi-setup.php +++ b/plugins/installDatabase/InstallSchema.civi-setup.php @@ -65,6 +65,10 @@ public function checkSqlFiles(\Civi\Setup\Event\CheckRequirementsEvent $e) { } } + if (!file_exists($e->getModel()->settingsPath)) { + $e->addError('system', 'settingsPath', sprintf('The CiviCRM setting file is missing.')); + } + $e->addInfo('system', 'lang', "Language $seedLanguage is allowed."); } @@ -76,11 +80,10 @@ public function installDatabase(\Civi\Setup\Event\InstallDatabaseEvent $e) { $sqlPath = $model->srcPath . DIRECTORY_SEPARATOR . 'sql'; $spec = $this->loadSpecification($model->srcPath); - \Civi\Setup::log()->info(sprintf('[%s] generateCreateSql', basename(__FILE__))); - \Civi\Setup\DbUtil::sourceSQL($model->db, \Civi\Setup\DbUtil::generateCreateSql($model->srcPath, $spec->database, $spec->tables)); + require_once $model->settingsPath; - \Civi\Setup::log()->info(sprintf('[%s] generateNavigation', basename(__FILE__))); - \Civi\Setup\DbUtil::sourceSQL($model->db, \Civi\Setup\DbUtil::generateNavigation($model->srcPath)); + \Civi\Setup::log()->info(sprintf('[%s] generateCreateSql', basename(__FILE__))); + \Civi\Setup\DbUtil::sourceSQL($model->db, \Civi\Setup\DbUtil::generateCreateSql($model->srcPath, $model->db['database'], $spec->tables)); if (!empty($model->loadGenerated)) { \Civi\Setup::log()->info(sprintf('[%s] generateSample', basename(__FILE__))); @@ -98,6 +101,9 @@ public function installDatabase(\Civi\Setup\Event\InstallDatabaseEvent $e) { \Civi\Setup\DbUtil::sourceSQL($model->db, file_get_contents($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_acl.mysql')); } } + + \Civi\Setup::log()->info(sprintf('[%s] generateNavigation', basename(__FILE__))); + \Civi\Setup\DbUtil::sourceSQL($model->db, \Civi\Setup\DbUtil::generateNavigation($model->srcPath)); } /** diff --git a/src/Setup.php b/src/Setup.php index ffb1a29..43cfebf 100644 --- a/src/Setup.php +++ b/src/Setup.php @@ -71,10 +71,23 @@ public static function init($modelValues = array(), $pluginCallback = NULL, $log $pluginDir = dirname(__DIR__) . '/plugins'; $pluginFiles = array(); - foreach (['*.civi-setup.php', '*/*.civi-setup.php'] as $pattern) { - foreach ((array) glob("$pluginDir/$pattern") as $file) { - $key = substr($file, strlen($pluginDir) + 1); - $key = preg_replace('/\.civi-setup\.php$/', '', $key); + $pluginFileDirs = [ + 'blocks', + 'checkInstalled', + 'checkRequirements', + 'common', + 'createForm', + 'init', + 'installFiles', + 'installDatabase', + ]; + // Don't include uninstall plugin files, as this need to be called on demand and shoudn't be part of Civi installtion setup + foreach ($pluginFileDirs as $pattern) { + foreach ((array) glob("$pluginDir/$pattern/*") as $file) { + if (!strstr($file, '.civi-setup.php')) { + continue; + } + $key = preg_replace('/\.civi-setup\.php$/', '', $file); $pluginFiles[$key] = $file; } } diff --git a/src/Setup/DbUtil.php b/src/Setup/DbUtil.php index d731543..1e35248 100644 --- a/src/Setup/DbUtil.php +++ b/src/Setup/DbUtil.php @@ -30,7 +30,7 @@ public static function encodeDsn($db) { return sprintf('mysql://%s:%s@%s/%s', $db['username'], $db['password'], - self::encodeHostPort($db['host'], $db['port']), + $db['server']?: self::encodeHostPort($db['host'], $db['port']), $db['database'] ); }