Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup.sh - Fixes for running in basic composer file-structure #16408

Merged
merged 3 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CRM/Core/CodeGen/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public function setupCms() {
* path to config template
*/
public function findConfigTemplate($cms) {
if (getenv('GENCODE_CONFIG_TEMPLATE')) {
return getenv('GENCODE_CONFIG_TEMPLATE');
}

$candidates = [];
switch ($cms) {
case 'backdrop':
Expand Down
5 changes: 4 additions & 1 deletion CRM/Core/CodeGen/Util/Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ public function getCompileDir() {
*/
public function createSmarty() {
$base = dirname(dirname(dirname(dirname(__DIR__))));
$pkgs = file_exists(dirname($base) . "/civicrm-packages") ? dirname($base) . "/civicrm-packages" : "$base/packages";

require_once 'Smarty/Smarty.class.php';
$smarty = new Smarty();
$smarty->template_dir = "$base/xml/templates";
$smarty->plugins_dir = ["$base/packages/Smarty/plugins", "$base/CRM/Core/Smarty/plugins"];
$smarty->plugins_dir = ["$pkgs/Smarty/plugins", "$base/CRM/Core/Smarty/plugins"];
$smarty->compile_dir = $this->getCompileDir();
$smarty->clear_all_cache();

Expand All @@ -59,6 +60,8 @@ public function createSmarty() {
require_once 'CRM/Core/Smarty/plugins/block.localize.php';
$smarty->register_block('localize', 'smarty_block_localize');

$smarty->assign('gencodeXmlDir', dirname(dirname(dirname(dirname(__DIR__)))) . '/xml');

return $smarty;
}

Expand Down
6 changes: 4 additions & 2 deletions bin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ set -x

if [ -n "$DO_DOWNLOAD" ]; then
pushd "$CALLEDPATH/.."
COMPOSER=$(pickcmd composer composer.phar)
$COMPOSER install
if [ "$GENCODE_CMS" != "Drupal8" ]; then
COMPOSER=$(pickcmd composer composer.phar)
$COMPOSER install
fi

if has_commands karma ; then
## dev dependencies have been installed globally; don't force developer to redownload
Expand Down
3 changes: 2 additions & 1 deletion xml/GenCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
die("GenCode can only be run from command line.");
}

ini_set('include_path', '.' . PATH_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR . '..');
$includes = ['.', '../packages', '../../civicrm-packages', '..'];
ini_set('include_path', implode(PATH_SEPARATOR, $includes));
Copy link
Member Author

@totten totten Jan 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original mix of PATH_SEPARATOR and DIRECTORY_SEPARATOR and dots might make your eyes glaze over. (At least, it made my eyes glaze over...) Trying to summarize this bit, it:

  • Switches to array notation to make it is easier to read
  • Retains all the existing items in the search-list (., ../packages, ..)
  • Adds a new item to the search-list (../../civicrm-packages)

// make sure the memory_limit is at least 512 MB
$memLimitString = trim(ini_get('memory_limit'));
$memLimitUnit = strtolower(substr($memLimitString, -1));
Expand Down
8 changes: 4 additions & 4 deletions xml/templates/civicrm_msg_template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ INSERT INTO civicrm_msg_template
(msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES
{foreach from=$ovNames key=gName item=ovs name=for_groups}
{foreach from=$ovs key=vName item=title name=for_values}
{fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../xml/templates/message_templates/`$vName`_subject.tpl"}
{fetch assign=text file="`$smarty.const.SMARTY_DIR`/../../xml/templates/message_templates/`$vName`_text.tpl"}
{fetch assign=html file="`$smarty.const.SMARTY_DIR`/../../xml/templates/message_templates/`$vName`_html.tpl"}
{fetch assign=subject file="`$gencodeXmlDir`/templates/message_templates/`$vName`_subject.tpl"}
{fetch assign=text file="`$gencodeXmlDir`/templates/message_templates/`$vName`_text.tpl"}
{fetch assign=html file="`$gencodeXmlDir`/templates/message_templates/`$vName`_html.tpl"}
('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1, 0),
('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 0, 1) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
{/foreach}
{/foreach}

{php}
$dir = SMARTY_DIR . '/../../xml/templates/message_templates/sample';
$dir = $this->_tpl_vars['gencodeXmlDir'] . '/templates/message_templates/sample';
$templates = array();
foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
$templates[] = array('name' => basename($filename, '.tpl'), 'filename' => "$dir/$filename");
Expand Down