From 3e31860eddaee24ec6d2e2d96df038028cfba70f Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Thu, 25 Oct 2007 22:03:59 +0000 Subject: [PATCH] Troubleshooting why this does not work and I cleaned up the code. --- lib/Doctrine/I18n.php | 22 ++++++++++++++++------ lib/Doctrine/Plugin.php | 6 +++--- lib/Doctrine/Template/I18n.php | 22 +++++++++++++++++++++- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/I18n.php b/lib/Doctrine/I18n.php index 7bafe7f11..cdb291f1c 100644 --- a/lib/Doctrine/I18n.php +++ b/lib/Doctrine/I18n.php @@ -40,18 +40,28 @@ class Doctrine_I18n extends Doctrine_Plugin 'pluginTable' => false, ); - protected $_auditTable; - + /** + * __construct + * + * @param string $options + * @return void + */ public function __construct($options) { $this->_options = array_merge($this->_options, $options); } + /** + * buildDefinition + * + * @param object $Doctrine_Table + * @return void + */ public function buildDefinition(Doctrine_Table $table) { - if (empty($this->_options['fields'])) { - throw new Doctrine_I18n_Exception('Fields not set.'); - } + if (empty($this->_options['fields'])) { + throw new Doctrine_I18n_Exception('Fields not set.'); + } $this->_options['className'] = str_replace('%CLASS%', $this->_options['table']->getComponentName(), @@ -115,4 +125,4 @@ class Doctrine_I18n extends Doctrine_Plugin return true; } -} +} \ No newline at end of file diff --git a/lib/Doctrine/Plugin.php b/lib/Doctrine/Plugin.php index 71a6ab4a8..41681e40d 100644 --- a/lib/Doctrine/Plugin.php +++ b/lib/Doctrine/Plugin.php @@ -169,15 +169,15 @@ class Doctrine_Plugin if ($this->_options['generateFiles']) { if (isset($this->_options['generatePath']) && $this->_options['generatePath']) { $builder->setTargetPath($this->_options['generatePath']); - + $builder->buildRecord($options, $columns, $relations); } else { throw new Doctrine_Plugin_Exception('If you wish to generate files then you must specify the path to generate the files in.'); } } else { $def = $builder->buildDefinition($options, $columns, $relations); - + eval($def); } } -} +} \ No newline at end of file diff --git a/lib/Doctrine/Template/I18n.php b/lib/Doctrine/Template/I18n.php index 667c61fb9..07745da5d 100644 --- a/lib/Doctrine/Template/I18n.php +++ b/lib/Doctrine/Template/I18n.php @@ -34,7 +34,12 @@ class Doctrine_Template_I18n extends Doctrine_Template { protected $_translation; - + /** + * __construct + * + * @param string $array + * @return void + */ public function __construct(array $options) { $this->_plugin = new Doctrine_I18n($options); @@ -42,6 +47,7 @@ class Doctrine_Template_I18n extends Doctrine_Template /** * translation + * * sets or retrieves the current translation language * * @return Doctrine_Record this object @@ -49,7 +55,15 @@ class Doctrine_Template_I18n extends Doctrine_Template public function translation($language = null) { $this->_translation = $language; + + return $this->_translation; } + + /** + * setUp + * + * @return void + */ public function setUp() { $this->_plugin->setOption('table', $this->_table); @@ -67,6 +81,12 @@ class Doctrine_Template_I18n extends Doctrine_Template $this->hasMany($className . ' as Translation', array('local' => $id, 'foreign' => $id)); } + + /** + * getI18n + * + * @return void + */ public function getI18n() { return $this->_plugin;