| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Create classes which are used for schema introspection. |
| 5 | */ |
| 6 | class CRM_Core_CodeGen_Reflection extends CRM_Core_CodeGen_BaseTask { |
| 7 | |
| 8 | /** |
| 9 | * @return bool |
| 10 | * TRUE if an update is needed. |
| 11 | */ |
| 12 | public function needsUpdate() { |
| 13 | // Generating this file is fairly cheap, and we don't have robust heuristic |
| 14 | // for the checksum. |
| 15 | |
| 16 | // skip this task on test environment as the schema generation should only be triggered during installation/upgrade |
| 17 | if (CIVICRM_UF == 'UnitTests') { |
| 18 | return FALSE; |
| 19 | } |
| 20 | |
| 21 | return TRUE; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Run generator. |
| 26 | */ |
| 27 | public function run() { |
| 28 | echo "Generating table list\n"; |
| 29 | $template = new CRM_Core_CodeGen_Util_Template('php', FALSE); |
| 30 | $template->assign('tables', $this->tables); |
| 31 | $template->assign('genCodeChecksum', 'IGNORE'); |
| 32 | $template->run('listAll.tpl', $this->getAbsFileName()); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Get absolute file name. |
| 37 | * |
| 38 | * @return string |
| 39 | */ |
| 40 | protected function getAbsFileName() { |
| 41 | return $this->config->CoreDAOCodePath . "AllCoreTables.data.php"; |
| 42 | } |
| 43 | |
| 44 | } |