From: Tim Otten Date: Wed, 27 Jul 2016 05:29:41 +0000 (-0700) Subject: CRM-14885 - CRM_Core_CodeGen_DAO - Separate instances for each DAO file X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=37254324f511503924b16bed9bb563fecfacdfe7;p=civicrm-core.git CRM-14885 - CRM_Core_CodeGen_DAO - Separate instances for each DAO file --- diff --git a/CRM/Core/CodeGen/DAO.php b/CRM/Core/CodeGen/DAO.php index ea04ce8459..13cffd5250 100644 --- a/CRM/Core/CodeGen/DAO.php +++ b/CRM/Core/CodeGen/DAO.php @@ -4,26 +4,33 @@ * 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']); } + } diff --git a/CRM/Core/CodeGen/Main.php b/CRM/Core/CodeGen/Main.php index 99ce0e153a..0c3674fb9e 100644 --- a/CRM/Core/CodeGen/Main.php +++ b/CRM/Core/CodeGen/Main.php @@ -102,7 +102,9 @@ Alternatively you can get a version of CiviCRM that matches your PHP version $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; }