Merge pull request #19522 from eileenmcnaughton/ref_template
[civicrm-core.git] / xml / GenCode.php
CommitLineData
6a488035 1<?php
e06b5e14
TO
2
3if (PHP_SAPI !== 'cli') {
4 die("GenCode can only be run from command line.");
5}
6
0825dc24
TO
7$includes = ['.', '../packages', '../../civicrm-packages', '..'];
8ini_set('include_path', implode(PATH_SEPARATOR, $includes));
0d035206 9// make sure the memory_limit is at least 512 MB
10$memLimitString = trim(ini_get('memory_limit'));
56fdfc52
TO
11$memLimitUnit = strtolower(substr($memLimitString, -1));
12$memLimit = (int) $memLimitString;
0d035206 13switch ($memLimitUnit) {
56fdfc52
TO
14 case 'g':
15 $memLimit *= 1024;
16 case 'm':
17 $memLimit *= 1024;
18 case 'k':
19 $memLimit *= 1024;
0d035206 20}
21
22if ($memLimit >= 0 and $memLimit < 536870912) {
8652384e
TO
23 // Note: When processing all locales, CRM_Core_I18n::singleton() eats a lot of RAM.
24 ini_set('memory_limit', -1);
0d035206 25}
683bf891
SL
26// avoid php warnings if timezone is not set - CRM-10844
27date_default_timezone_set('UTC');
6a488035
TO
28
29define('CIVICRM_UF', 'Drupal');
2a8330d8 30define('CIVICRM_UF_BASEURL', '/');
1b94154b 31define('CIVICRM_L10N_BASEDIR', getenv('CIVICRM_L10N_BASEDIR') ? getenv('CIVICRM_L10N_BASEDIR') : __DIR__ . '/../l10n');
b0c5bdb4 32$GLOBALS['civicrm_paths']['cms.root']['url'] = 'http://gencode.example.com/do-not-use';
6a488035
TO
33
34require_once 'CRM/Core/ClassLoader.php';
35CRM_Core_ClassLoader::singleton()->register();
36
e39816b5
ARW
37# TODO: pull these settings from configuration
38$genCode = new CRM_Core_CodeGen_Main(
683bf891
SL
39 // $CoreDAOCodePath
40 '../CRM/Core/DAO/',
41 // $sqlCodePath
42 '../sql/',
43 // $phpCodePath
44 '../',
45 // $tplCodePath
46 '../templates/',
47 // IGNORE
48 NULL,
49 // cms
50 @$argv[3],
51 // db version
52 empty($argv[2]) ? NULL : $argv[2],
53 // schema file
54 empty($argv[1]) ? 'schema/Schema.xml' : $argv[1],
55 // path to digest file
56 getenv('CIVICRM_GENCODE_DIGEST') ? getenv('CIVICRM_GENCODE_DIGEST') : NULL
6a488035 57);
c59c0e21 58$genCode->main();