diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index 517b063df..2907778ec 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -1169,7 +1169,7 @@ class Doctrine_Export extends Doctrine_Connection_Module * * @param Doctrine_Table $table table object to retrieve the plugins from * @return array an array of Doctrine_Plugin objects - */ + */ public function getAllPlugins(Doctrine_Table $table) { $plugins = array(); @@ -1183,7 +1183,11 @@ class Doctrine_Export extends Doctrine_Connection_Module $plugins[] = $plugin; - $plugins = array_merge($plugins, $this->getAllPlugins($plugin->getOption('pluginTable'))); + $pluginTable = $plugin->getOption('pluginTable'); + + if ($pluginTable instanceof Doctrine_Table) { + $plugins = array_merge($plugins, $this->getAllPlugins($pluginTable)); + } } return $plugins; diff --git a/lib/Doctrine/I18n.php b/lib/Doctrine/I18n.php index cdb291f1c..3fea6f7dc 100644 --- a/lib/Doctrine/I18n.php +++ b/lib/Doctrine/I18n.php @@ -38,6 +38,7 @@ class Doctrine_I18n extends Doctrine_Plugin 'generateFiles' => false, 'table' => false, 'pluginTable' => false, + 'children' => array(), ); /** @@ -123,6 +124,8 @@ class Doctrine_I18n extends Doctrine_Plugin $this->_options['pluginTable']->bindQueryPart('indexBy', 'lang'); + $this->generateChildDefinitions(); + return true; } -} \ No newline at end of file +} diff --git a/lib/Doctrine/Plugin.php b/lib/Doctrine/Plugin.php index 41681e40d..d4e8bb011 100644 --- a/lib/Doctrine/Plugin.php +++ b/lib/Doctrine/Plugin.php @@ -91,6 +91,11 @@ class Doctrine_Plugin return $this; } + public function addChild(Doctrine_Template $template) + { + $this->_options['children'][] = $template; + } + /** * returns all options and their associated values * @@ -101,6 +106,17 @@ class Doctrine_Plugin return $this->_options; } + public function generateChildDefinitions() + { + foreach ($this->_options['children'] as $child) { + $this->_options['pluginTable']->addTemplate(get_class($child), $child); + + $child->setTable($this->_options['pluginTable']); + + $child->setUp(); + } + } + /** * generates foreign keys for the plugin table based on the owner table * @@ -180,4 +196,4 @@ class Doctrine_Plugin eval($def); } } -} \ No newline at end of file +} diff --git a/lib/Doctrine/Template.php b/lib/Doctrine/Template.php index 883843dea..91e46ca53 100644 --- a/lib/Doctrine/Template.php +++ b/lib/Doctrine/Template.php @@ -85,6 +85,14 @@ class Doctrine_Template extends Doctrine_Record_Abstract return $this->_invoker; } + public function addChild(Doctrine_Template $template) + { + $this->_plugin->addChild($template); + + return $this; + } + + public function getPlugin() { return $this->_plugin; diff --git a/lib/Doctrine/Template/I18n.php b/lib/Doctrine/Template/I18n.php index 0ca05519f..adfa1f8ed 100644 --- a/lib/Doctrine/Template/I18n.php +++ b/lib/Doctrine/Template/I18n.php @@ -32,8 +32,6 @@ */ class Doctrine_Template_I18n extends Doctrine_Template { - protected $_translation; - /** * __construct * @@ -44,21 +42,6 @@ class Doctrine_Template_I18n extends Doctrine_Template { $this->_plugin = new Doctrine_I18n($options); } - - /** - * translation - * - * sets or retrieves the current translation language - * - * @return Doctrine_Record this object - */ - public function translation($language = null) - { - $this->_translation = $language; - - return $this->_translation; - } - /** * setUp * @@ -91,4 +74,4 @@ class Doctrine_Template_I18n extends Doctrine_Template { return $this->_plugin; } -} \ No newline at end of file +} diff --git a/lib/Doctrine/Template/Searchable.php b/lib/Doctrine/Template/Searchable.php index 75954249e..56a682569 100644 --- a/lib/Doctrine/Template/Searchable.php +++ b/lib/Doctrine/Template/Searchable.php @@ -34,9 +34,7 @@ class Doctrine_Template_Searchable extends Doctrine_Template { public function __construct(array $options) { - $this->_plugin = new Doctrine_Search($options); - - + $this->_plugin = new Doctrine_Search($options); } public function getPlugin() diff --git a/lib/Doctrine/Template/Versionable.php b/lib/Doctrine/Template/Versionable.php index 65117a5a4..dcab9ec47 100644 --- a/lib/Doctrine/Template/Versionable.php +++ b/lib/Doctrine/Template/Versionable.php @@ -47,4 +47,5 @@ class Doctrine_Template_Versionable extends Doctrine_Template { return $this->_plugin; } + }