Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
reorder install plugins and other minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Feb 19, 2018
1 parent 43cb952 commit 48bcc94
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
14 changes: 10 additions & 4 deletions plugins/installDatabase/InstallSchema.civi-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}

Expand All @@ -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__)));
Expand All @@ -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));
}

/**
Expand Down
21 changes: 17 additions & 4 deletions src/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Setup/DbUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
}
Expand Down

0 comments on commit 48bcc94

Please sign in to comment.