4 * Class CRM_Core_CodeGen_Main
6 class CRM_Core_CodeGen_Main
{
10 * drupal, joomla, wordpress
15 public $CoreDAOCodePath;
20 * ex: schema/Schema.xml
26 * Definitions of all tables.
29 * Ex: $tables['civicrm_address_format']['className'] = 'CRM_Core_DAO_AddressFormat';
35 * Ex: $database['tableAttributes_modern'] = "ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
40 * Path in which to store a marker that indicates the last execution of GenCode.
42 * If a matching marker already exists, GenCode doesn't run.
49 * Digest of the inputs to the code-generator (eg the properties and source files).
56 * @param $CoreDAOCodePath
66 public function __construct($CoreDAOCodePath, $sqlCodePath, $phpCodePath, $tplCodePath, $IGNORE, $argCms, $argVersion, $schemaPath, $digestPath) {
67 $this->CoreDAOCodePath
= $CoreDAOCodePath;
68 $this->sqlCodePath
= $sqlCodePath;
69 $this->phpCodePath
= $phpCodePath;
70 $this->tplCodePath
= $tplCodePath;
71 $this->digestPath
= $digestPath;
72 $this->sourceDigest
= NULL;
74 // default cms is 'drupal', if not specified
75 $this->cms
= isset($argCms) ?
strtolower($argCms) : 'drupal';
77 $versionFile = $this->phpCodePath
. "/xml/version.xml";
78 $versionXML = CRM_Core_CodeGen_Util_Xml
::parse($versionFile);
79 $this->db_version
= $versionXML->version_no
;
80 $this->buildVersion
= preg_replace('/^(\d{1,2}\.\d{1,2})\.(\d{1,2}|\w{4,7})$/i', '$1', $this->db_version
);
81 if (isset($argVersion)) {
82 // change the version to that explicitly passed, if any
83 $this->db_version
= $argVersion;
86 $this->schemaPath
= $schemaPath;
90 * Automatically generate a variety of files.
92 public function main() {
93 echo "\ncivicrm_domain.version := " . $this->db_version
. "\n\n";
94 if ($this->buildVersion
< 1.1) {
95 echo "The Database is not compatible for this version";
99 if (substr(phpversion(), 0, 1) < 5) {
100 echo phpversion() . ', ' . substr(phpversion(), 0, 1) . "\n";
102 CiviCRM requires a PHP Version >= 5
103 Please upgrade your php / webserver configuration
104 Alternatively you can get a version of CiviCRM that matches your PHP version
109 foreach ($this->getTasks() as $task) {
110 if (getenv('GENCODE_FORCE') ||
$task->needsUpdate()) {
118 * Array<CRM_Core_CodeGen_ITask>.
121 public function getTasks() {
125 $tasks[] = new CRM_Core_CodeGen_Config($this);
126 $tasks[] = new CRM_Core_CodeGen_Reflection($this);
127 $tasks[] = new CRM_Core_CodeGen_Schema($this);
128 foreach (array_keys($this->tables
) as $name) {
129 $tasks[] = new CRM_Core_CodeGen_DAO($this, $name);
131 $tasks[] = new CRM_Core_CodeGen_I18n($this);
138 public function init() {
139 if (!$this->database ||
!$this->tables
) {
140 $specification = new CRM_Core_CodeGen_Specification();
141 $specification->parse($this->schemaPath
, $this->buildVersion
);
142 $this->database
= $specification->database
;
143 $this->tables
= $specification->tables
;