This repository has been archived by the owner on Aug 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Simplify SQL and translation pipeline changes #9
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d2672ca
Simplify SQL and translation pipeline changes
monishdeb e85d19e
Add CRM_Core_CodeGen_Schema code to InstallSchema.civi-setup.php
monishdeb 1b022b1
use SQL content rather then filename to populate mysql data
monishdeb f347d6d
AvailableTables - Quiet
totten eff38f6
InstallSchema - Fix path reference. Display more fine-grained messages.
totten 552d0aa
FileUtil - Fix createTempDir()
totten e75c2bc
Template.php - Multiple fixes
totten bf76ef6
DbUtil - Fix misnamed param. Throw error when running unsupported mode.
totten 463b730
SmartyUtil - Ensure that {ts}/ts() is available
totten fa0824b
UninstallSettingsFile - Tweak error message
totten 7bd6d16
DbUtil - Remove extra newlines from log
totten b5734ec
Combine InstallSchema, AvailableTables
totten f64d492
InstallSchema - Convert from "listener" (closure) to "subscriber" (OO…
totten 87e3bf6
reorder install plugins and other minor fixes
monishdeb 09106d6
additional fixes
monishdeb 6ed179f
SchemaGenerator, InstallSchema - More consistent log output
totten 0d8c119
InstallSchema - Allow `ts()` to work without booting `CRM_Core_DAO`
totten 66da8e8
multilingual fix
monishdeb 4f0315a
additional fixes
monishdeb c3bed33
SchemaGenerator::generateSample - Use the full version
totten 839da8f
InstallSchema - Split `generateSample()`. Preserve old behavior.
totten a109dda
SchemaGenerator - Simplify code-style for calling civicrm_navigation.tpl
totten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
namespace Civi\Setup; | ||
|
||
use Civi\Setup\Template; | ||
|
||
class SchemaGenerator { | ||
|
||
/** | ||
* Return translated SQL content using tpl, mainly contain SQL codes on table CREATE/DROP | ||
* | ||
* @param string $srcPath | ||
* @param array $database | ||
* @param array $tables | ||
* @return string | ||
*/ | ||
public static function generateCreateSql($srcPath, $database, $tables) { | ||
$template = new Template($srcPath, 'sql'); | ||
|
||
$template->assign('database', $database); | ||
$template->assign('tables', $tables); | ||
$dropOrder = array_reverse(array_keys($tables)); | ||
$template->assign('dropOrder', $dropOrder); | ||
$template->assign('mysql', 'modern'); | ||
|
||
return $template->getContent('schema.tpl'); | ||
} | ||
|
||
/** | ||
* Generate an example set of data, including the basic data as well | ||
* as some example records/entities (e.g. case-types, membership types). | ||
* | ||
* @param string $srcPath | ||
* | ||
* @return string | ||
*/ | ||
public static function generateSampleData($srcPath) { | ||
$versionFile = implode(DIRECTORY_SEPARATOR, [$srcPath, 'xml', 'version.xml']); | ||
$xml = \CRM_Core_CodeGen_Util_Xml::parse($versionFile); | ||
|
||
$template = new Template($srcPath, 'sql'); | ||
$template->assign('db_version', $xml->version_no); | ||
|
||
// If you're going to use the full data generator... | ||
// "DROP TABLE IF EXISTS zipcodes" | ||
// .... file_get_contents($sqlPath . DIRECTORY_SEPARATOR . 'zipcodes.mysql')... | ||
|
||
$sections = [ | ||
'civicrm_country.tpl', | ||
'civicrm_state_province.tpl', | ||
'civicrm_currency.tpl', | ||
'civicrm_data.tpl', | ||
'civicrm_acl.tpl', | ||
'civicrm_sample.tpl', | ||
'case_sample.tpl', | ||
'civicrm_version_sql.tpl', | ||
'civicrm_navigation.tpl', | ||
]; | ||
|
||
// DROP TABLE IF EXISTS zipcodes; | ||
|
||
return $template->getConcatContent($sections); | ||
} | ||
|
||
/** | ||
* Generate a minimalist set of basic data, such as | ||
* common option-values and countries. | ||
* | ||
* @param string $srcPath | ||
* | ||
* @return string | ||
* SQL | ||
*/ | ||
public static function generateBasicData($srcPath) { | ||
$versionFile = implode(DIRECTORY_SEPARATOR, [$srcPath, 'xml', 'version.xml']); | ||
$xml = \CRM_Core_CodeGen_Util_Xml::parse($versionFile); | ||
|
||
$template = new Template($srcPath, 'sql'); | ||
$template->assign('db_version', $xml->version_no); | ||
|
||
$sections = [ | ||
'civicrm_country.tpl', | ||
'civicrm_state_province.tpl', | ||
'civicrm_currency.tpl', | ||
'civicrm_data.tpl', | ||
'civicrm_acl.tpl', | ||
'civicrm_version_sql.tpl', | ||
'civicrm_navigation.tpl', | ||
]; | ||
return $template->getConcatContent($sections); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
namespace Civi\Setup; | ||
|
||
class SmartyUtil { | ||
|
||
/** | ||
* Create a Smarty instance. | ||
* | ||
* @return \Smarty | ||
*/ | ||
public static function createSmarty($srcPath) { | ||
require_once 'CRM/Core/I18n.php'; | ||
|
||
$packagePath = implode(DIRECTORY_SEPARATOR, [$srcPath, 'packages']); | ||
require_once $packagePath . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'Smarty.class.php'; | ||
|
||
$smarty = new \Smarty(); | ||
$smarty->template_dir = implode(DIRECTORY_SEPARATOR, [$srcPath, 'xml', 'templates']); | ||
$smarty->plugins_dir = [ | ||
implode(DIRECTORY_SEPARATOR, [$packagePath, 'Smarty', 'plugins']), | ||
implode(DIRECTORY_SEPARATOR, [$srcPath, 'CRM', 'Core', 'Smarty', 'plugins']), | ||
]; | ||
$smarty->compile_dir = \Civi\Setup\FileUtil::createTempDir('templates_c'); | ||
$smarty->clear_all_cache(); | ||
|
||
// CRM-5308 / CRM-3507 - we need {localize} to work in the templates | ||
require_once implode(DIRECTORY_SEPARATOR, [$srcPath, 'CRM', 'Core', 'Smarty', 'plugins', 'block.localize.php']); | ||
$smarty->register_block('localize', 'smarty_block_localize'); | ||
|
||
return $smarty; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this cause people with non standard ports to have issues? or is
$db['server']
defined further upThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seamuslee001 yes its defined up where
parseDsn(...)
will return the db creds, among which theserver
attribute will be first encoded with host and port information. See here