4 * Create classes which are used for schema introspection.
6 class CRM_Core_CodeGen_Reflection
extends CRM_Core_CodeGen_BaseTask
{
17 * TRUE if an update is needed.
19 public function needsUpdate() {
20 if (!file_exists($this->getAbsFileName())) {
24 if ($this->getSchemaChecksum() !== self
::extractRegex($this->getAbsFileName(), ';\(GenCodeChecksum:([a-zA-Z0-9]+)\);')) {
28 return !$this->isApproxPhpMatch(
29 file_get_contents($this->getAbsFileName()),
34 public function run() {
35 echo "Generating table list\n";
36 $template = new CRM_Core_CodeGen_Util_Template('php');
37 $template->assign('tables', $this->tables
);
38 $template->assign('genCodeChecksum', $this->getSchemaChecksum());
39 $template->run('listAll.tpl', $this->getAbsFileName());
43 * Generate the raw PHP code for the data file.
47 public function getRaw() {
49 $template = new CRM_Core_CodeGen_Util_Template('php');
50 $template->assign('tables', $this->tables
);
51 $template->assign('genCodeChecksum', 'NEW');
52 $this->raw
= $template->fetch('listAll.tpl');
60 protected function getAbsFileName() {
61 return $this->config
->CoreDAOCodePath
. "AllCoreTables.data.php";
64 protected function getSchemaChecksum() {
65 if (!$this->checksum
) {
66 CRM_Utils_Array
::flatten($this->tables
, $flat);
68 $this->checksum
= md5(json_encode($flat));
70 return $this->checksum
;