* Create DAO ORM classes.
*/
class CRM_Core_CodeGen_DAO extends CRM_Core_CodeGen_BaseTask {
- public function run() {
- $this->generateDAOs();
+
+ /**
+ * @var string
+ */
+ public $name;
+
+ public function __construct($config, $name) {
+ parent::__construct($config);
+ $this->name = $name;
}
- public function generateDAOs() {
- foreach (array_keys($this->tables) as $name) {
- echo "Generating $name as " . $this->tables[$name]['fileName'] . "\n";
+ public function run() {
+ $name = $this->name;
+ echo "Generating $name as " . $this->tables[$name]['fileName'] . "\n";
- if (empty($this->tables[$name]['base'])) {
- echo "No base defined for $name, skipping output generation\n";
- continue;
- }
+ if (empty($this->tables[$name]['base'])) {
+ echo "No base defined for $name, skipping output generation\n";
+ return;
+ }
- $template = new CRM_Core_CodeGen_Util_Template('php');
- $template->assign('table', $this->tables[$name]);
+ $template = new CRM_Core_CodeGen_Util_Template('php');
+ $template->assign('table', $this->tables[$name]);
- $directory = $this->config->phpCodePath . $this->tables[$name]['base'];
- CRM_Core_CodeGen_Util_File::createDir($directory);
+ $directory = $this->config->phpCodePath . $this->tables[$name]['base'];
+ CRM_Core_CodeGen_Util_File::createDir($directory);
- $template->run('dao.tpl', $directory . $this->tables[$name]['fileName']);
- }
+ $template->run('dao.tpl', $directory . $this->tables[$name]['fileName']);
}
+
}
$tasks[] = new CRM_Core_CodeGen_Config($this);
$tasks[] = new CRM_Core_CodeGen_Reflection($this);
$tasks[] = new CRM_Core_CodeGen_Schema($this);
- $tasks[] = new CRM_Core_CodeGen_DAO($this);
+ foreach (array_keys($this->tables) as $name) {
+ $tasks[] = new CRM_Core_CodeGen_DAO($this, $name);
+ }
$tasks[] = new CRM_Core_CodeGen_I18n($this);
return $tasks;
}