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()),
37 public function run() {
38 echo "Generating table list\n";
39 $template = new CRM_Core_CodeGen_Util_Template('php');
40 $template->assign('tables', $this->tables
);
41 $template->assign('genCodeChecksum', $this->getSchemaChecksum());
42 $template->run('listAll.tpl', $this->getAbsFileName());
46 * Generate the raw PHP code for the data file.
50 public function getRaw() {
52 $template = new CRM_Core_CodeGen_Util_Template('php');
53 $template->assign('tables', $this->tables
);
54 $template->assign('genCodeChecksum', 'NEW');
55 $this->raw
= $template->fetch('listAll.tpl');
61 * Get absolute file name.
65 protected function getAbsFileName() {
66 return $this->config
->CoreDAOCodePath
. "AllCoreTables.data.php";
70 * Get the checksum for the schema.
74 protected function getSchemaChecksum() {
75 if (!$this->checksum
) {
76 CRM_Utils_Array
::flatten($this->tables
, $flat);
78 $this->checksum
= md5(json_encode($flat));
80 return $this->checksum
;