4 * Class CRM_Core_CodeGen_Main
6 class CRM_Core_CodeGen_Main
{
14 * drupal, joomla, wordpress
19 public $CoreDAOCodePath;
24 * ex: schema/Schema.xml
30 * Definitions of all tables.
33 * Ex: $tables['civicrm_address_format']['className'] = 'CRM_Core_DAO_AddressFormat';
39 * Ex: $database['tableAttributes_modern'] = "ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
44 * Path in which to store a marker that indicates the last execution of GenCode.
46 * If a matching marker already exists, GenCode doesn't run.
53 * Digest of the inputs to the code-generator (eg the properties and source files).
60 * @param $CoreDAOCodePath
70 public function __construct($CoreDAOCodePath, $sqlCodePath, $phpCodePath, $tplCodePath, $IGNORE, $argCms, $argVersion, $schemaPath, $digestPath) {
71 $this->CoreDAOCodePath
= $CoreDAOCodePath;
72 $this->sqlCodePath
= $sqlCodePath;
73 $this->phpCodePath
= $phpCodePath;
74 $this->tplCodePath
= $tplCodePath;
75 $this->digestPath
= $digestPath;
76 $this->sourceDigest
= NULL;
78 // default cms is 'drupal', if not specified
79 $this->cms
= isset($argCms) ?
strtolower($argCms) : 'drupal';
81 $versionFile = $this->phpCodePath
. "/xml/version.xml";
82 $versionXML = CRM_Core_CodeGen_Util_Xml
::parse($versionFile);
83 $this->db_version
= (string) $versionXML->version_no
;
84 $this->buildVersion
= preg_replace('/^(\d{1,2}\.\d{1,2})\.(\d{1,2}|\w{4,7})$/i', '$1', $this->db_version
);
85 if (isset($argVersion)) {
86 // change the version to that explicitly passed, if any
87 $this->db_version
= (string) $argVersion;
90 $this->schemaPath
= $schemaPath;
94 * Automatically generate a variety of files.
96 public function main() {
97 echo "\ncivicrm_domain.version := " . $this->db_version
. "\n\n";
98 if ($this->buildVersion
< 1.1) {
99 echo "The Database is not compatible for this version";
103 if (substr(phpversion(), 0, 1) < 5) {
104 echo phpversion() . ', ' . substr(phpversion(), 0, 1) . "\n";
106 CiviCRM requires a PHP Version >= 5
107 Please upgrade your php / webserver configuration
108 Alternatively you can get a version of CiviCRM that matches your PHP version
113 foreach ($this->getTasks() as $task) {
114 if (getenv('GENCODE_FORCE') ||
$task->needsUpdate()) {
122 * Array<CRM_Core_CodeGen_ITask>.
125 public function getTasks() {
129 $tasks[] = new CRM_Core_CodeGen_Config($this);
130 $tasks[] = new CRM_Core_CodeGen_Reflection($this);
131 $tasks[] = new CRM_Core_CodeGen_Schema($this);
132 foreach (array_keys($this->tables
) as $name) {
133 $tasks[] = new CRM_Core_CodeGen_DAO($this, $name);
135 $tasks[] = new CRM_Core_CodeGen_I18n($this);
142 public function init() {
143 if (!$this->database ||
!$this->tables
) {
144 $specification = new CRM_Core_CodeGen_Specification();
145 $specification->parse($this->schemaPath
, $this->buildVersion
);
146 $this->database
= $specification->database
;
147 $this->tables
= $specification->tables
;