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(
24 echo "Config file for '{$this->config->cms}' not known.";
27 elseif ($this->config
->cms
!== 'joomla') {
28 $configTemplate = $this->findConfigTemplate($this->config
->cms
);
29 if ($configTemplate) {
30 echo "Generating civicrm.config.php\n";
31 copy($configTemplate, '../civicrm.config.php');
34 throw new Exception("Failed to locate template for civicrm.config.php");
38 echo "Generating civicrm-version file\n";
39 $template = new CRM_Core_CodeGen_Util_Template('php');
40 $template->assign('db_version', $this->config
->db_version
);
41 $template->assign('cms', ucwords($this->config
->cms
));
42 $template->run('civicrm_version.tpl', $this->config
->phpCodePath
. "civicrm-version.php");
47 * "drupal"|"wordpress".
49 * path to config template
51 public function findConfigTemplate($cms) {
52 $candidates = array();
55 $candidates[] = "../drupal/civicrm.config.php.drupal";
56 $candidates[] = "../../drupal/civicrm.config.php.drupal";
60 $candidates[] = "../../modules/civicrm/civicrm.config.php.drupal";
61 $candidates[] = "../../../modules/civicrm/civicrm.config.php.drupal";
65 $candidates[] = "../../civicrm.config.php.wordpress";
66 $candidates[] = "../WordPress/civicrm.config.php.wordpress";
67 $candidates[] = "../drupal/civicrm.config.php.drupal";
70 foreach ($candidates as $candidate) {
71 if (file_exists($candidate)) {