function generateDAOs() {
foreach (array_keys($this->tables) as $name) {
- echo "Generating $name as " . $this->tables[$name]['fileName'] . "\n";
+ echo "Generating DAO " . $this->tables[$name]['fileName'] . " for $name \n";
if (empty($this->tables[$name]['base'])) {
echo "No base defined for $name, skipping output generation\n";
<?php
/**
- * Create DAO ORM classes.
+ * Create ORM entities
*/
class CRM_Core_CodeGen_Entity extends CRM_Core_CodeGen_BaseTask {
function run() {
function generateEntitys() {
foreach (array_keys($this->tables) as $name) {
- echo "Generating $name as " . $this->tables[$name]['fileName'] . "\n";
+ echo "Generating entity " . $this->tables[$name]['fileName'] ." for $name \n";
if (empty($this->tables[$name]['base'])) {
echo "No base defined for $name, skipping output generation\n";
continue;
}
- $template = new CRM_Core_CodeGen_Util_Template('php');
+ $template = new CRM_Core_CodeGen_Util_Template('');
$template->assign('table', $this->tables[$name]);
$directory = $this->config->phpCodePath . $this->tables[$name]['base'];
$klass = trim((string ) $tableXML->class);
$base = $this->value('base', $tableXML);
$sourceFile = "xml/schema/{$base}/{$klass}.xml";
- //$daoPath = "{$base}/DAO/";
$daoPath = "{$base}" . DIRECTORY_SEPARATOR;
$pre = str_replace('/', '_', $daoPath);
$this->classNames[$name] = $pre . $klass;
$table = array(
'name' => $name,
- //'base' => $daoPath,
- 'base' => 'src2'. DIRECTORY_SEPARATOR .str_replace('CRM', 'Civi', $daoPath),
+ 'base' => str_replace('CRM', 'Civi', $daoPath),
'sourceFile' => $sourceFile,
'fileName' => $klass . '.php',
'objectName' => $klass,
'labelName' => substr($name, 8),
- //'className' => $this->classNames[$name],
'className' => $klass,
'attributes_simple' => trim($database['tableAttributes_simple']),
'attributes_modern' => trim($database['tableAttributes_modern']),
exit();
}
- if (defined('CIVICRM_GEN_ENTITY') && CIVICRM_GEN_ENTITY) {
- $specification = new CRM_Core_CodeGen_EntitySpecification();
- }
- else {
- $specification = new CRM_Core_CodeGen_Specification();
- }
-
+ $specification = new CRM_Core_CodeGen_Specification();
$specification->parse($this->schemaPath, $this->buildVersion);
# cheese:
$this->database = $specification->database;
// TODO: This configuration can be manipulated dynamically.
$components = $this->getTasks();
foreach ($components as $component) {
+ // special handling for entity generation
+ if ($component == 'CRM_Core_CodeGen_Entity') {
+ $specification = new CRM_Core_CodeGen_EntitySpecification();
+ $specification->parse($this->schemaPath, $this->buildVersion);
+ $this->database = $specification->database;
+ $this->tables = $specification->tables;
+ }
+
$task = new $component($this);
if (is_a($task, 'CRM_Core_CodeGen_ITask')) {
'CRM_Core_CodeGen_Reflection',
'CRM_Core_CodeGen_Schema',
'CRM_Core_CodeGen_DAO',
- 'CRM_Core_CodeGen_Entity',
'CRM_Core_CodeGen_Test',
'CRM_Core_CodeGen_I18n',
+ 'CRM_Core_CodeGen_Entity',
);
return $components;
}
define('CIVICRM_UF', 'Drupal');
-// this should be true if you want to generate entities instead of DAO
-define('CIVICRM_GEN_ENTITY', FALSE);
-
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();