4 * Generate configuration files
6 class CRM_Core_CodeGen_Config
extends CRM_Core_CodeGen_BaseTask
{
8 $this->generateTemplateVersion();
13 function generateTemplateVersion() {
14 file_put_contents($this->config
->tplCodePath
. "/CRM/common/version.tpl", $this->config
->db_version
);
18 if (!in_array($this->config
->cms
, array(
19 'drupal', 'joomla', 'wordpress'))) {
20 echo "Config file for '{$this->config->cms}' not known.";
23 elseif ($this->config
->cms
!== 'joomla') {
24 $configTemplate = $this->findConfigTemplate($this->config
->cms
);
25 if ($configTemplate) {
26 echo "Generating civicrm.config.php\n";
27 copy($configTemplate, '../civicrm.config.php');
29 throw new Exception("Failed to locate template for civicrm.config.php");
33 echo "Generating civicrm-version file\n";
34 $template = new CRM_Core_CodeGen_Util_Template('php');
35 $template->assign('db_version', $this->config
->db_version
);
36 $template->assign('cms', ucwords($this->config
->cms
));
37 $template->run('civicrm_version.tpl', $this->config
->phpCodePath
. "civicrm-version.php");
41 * @param string $cms "drupal"|"wordpress"
42 * @return null|string path to config template
44 public function findConfigTemplate($cms) {
45 $candidates = array();
48 $candidates[] = "../drupal/civicrm.config.php.drupal";
49 $candidates[] = "../../drupal/civicrm.config.php.drupal";
52 $candidates[] = "../../civicrm.config.php.wordpress";
53 $candidates[] = "../WordPress/civicrm.config.php.wordpress";
54 $candidates[] = "../drupal/civicrm.config.php.drupal";
57 foreach ($candidates as $candidate) {
58 if (file_exists($candidate)) {