4 * Generate configuration files
6 class CRM_Core_CodeGen_Config
extends CRM_Core_CodeGen_BaseTask
{
7 public function run() {
8 $this->generateTemplateVersion();
13 public function generateTemplateVersion() {
14 file_put_contents($this->config
->tplCodePath
. "/CRM/common/version.tpl", $this->config
->db_version
);
17 public function setupCms() {
18 if (!in_array($this->config
->cms
, array(
25 echo "Config file for '{$this->config->cms}' not known.";
28 elseif ($this->config
->cms
!== 'joomla') {
29 $configTemplate = $this->findConfigTemplate($this->config
->cms
);
30 if ($configTemplate) {
31 echo "Generating civicrm.config.php\n";
32 copy($configTemplate, '../civicrm.config.php');
35 throw new Exception("Failed to locate template for civicrm.config.php");
39 echo "Generating civicrm-version file\n";
40 $template = new CRM_Core_CodeGen_Util_Template('php');
41 $template->assign('db_version', $this->config
->db_version
);
42 $template->assign('cms', ucwords($this->config
->cms
));
43 $template->run('civicrm_version.tpl', $this->config
->phpCodePath
. "civicrm-version.php");
48 * "drupal"|"wordpress".
50 * path to config template
52 public function findConfigTemplate($cms) {
53 $candidates = array();
57 $candidates[] = "../backdrop/civicrm.config.php.backdrop";
58 $candidates[] = "../../backdrop/civicrm.config.php.backdrop";
59 $candidates[] = "../drupal/civicrm.config.php.backdrop";
60 $candidates[] = "../../drupal/civicrm.config.php.backdrop";
64 $candidates[] = "../drupal/civicrm.config.php.drupal";
65 $candidates[] = "../../drupal/civicrm.config.php.drupal";
69 $candidates[] = "../../modules/civicrm/civicrm.config.php.drupal";
70 $candidates[] = "../../../modules/civicrm/civicrm.config.php.drupal";
74 $candidates[] = "../../civicrm.config.php.wordpress";
75 $candidates[] = "../WordPress/civicrm.config.php.wordpress";
76 $candidates[] = "../drupal/civicrm.config.php.drupal";
79 foreach ($candidates as $candidate) {
80 if (file_exists($candidate)) {