Commit 8e1f1578 authored by zYne's avatar zYne

nested plugin functionality added

parent edfd9f65
......@@ -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;
......
......@@ -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
}
......@@ -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
}
......@@ -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;
......
......@@ -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
}
......@@ -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()
......
......@@ -47,4 +47,5 @@ class Doctrine_Template_Versionable extends Doctrine_Template
{
return $this->_plugin;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment