Troubleshooting why this does not work and I cleaned up the code.
This commit is contained in:
parent
231b42eb67
commit
3e31860edd
@ -40,18 +40,28 @@ class Doctrine_I18n extends Doctrine_Plugin
|
|||||||
'pluginTable' => false,
|
'pluginTable' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_auditTable;
|
/**
|
||||||
|
* __construct
|
||||||
|
*
|
||||||
|
* @param string $options
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function __construct($options)
|
public function __construct($options)
|
||||||
{
|
{
|
||||||
$this->_options = array_merge($this->_options, $options);
|
$this->_options = array_merge($this->_options, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* buildDefinition
|
||||||
|
*
|
||||||
|
* @param object $Doctrine_Table
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function buildDefinition(Doctrine_Table $table)
|
public function buildDefinition(Doctrine_Table $table)
|
||||||
{
|
{
|
||||||
if (empty($this->_options['fields'])) {
|
if (empty($this->_options['fields'])) {
|
||||||
throw new Doctrine_I18n_Exception('Fields not set.');
|
throw new Doctrine_I18n_Exception('Fields not set.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_options['className'] = str_replace('%CLASS%',
|
$this->_options['className'] = str_replace('%CLASS%',
|
||||||
$this->_options['table']->getComponentName(),
|
$this->_options['table']->getComponentName(),
|
||||||
@ -115,4 +125,4 @@ class Doctrine_I18n extends Doctrine_Plugin
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -169,15 +169,15 @@ class Doctrine_Plugin
|
|||||||
if ($this->_options['generateFiles']) {
|
if ($this->_options['generateFiles']) {
|
||||||
if (isset($this->_options['generatePath']) && $this->_options['generatePath']) {
|
if (isset($this->_options['generatePath']) && $this->_options['generatePath']) {
|
||||||
$builder->setTargetPath($this->_options['generatePath']);
|
$builder->setTargetPath($this->_options['generatePath']);
|
||||||
|
|
||||||
$builder->buildRecord($options, $columns, $relations);
|
$builder->buildRecord($options, $columns, $relations);
|
||||||
} else {
|
} else {
|
||||||
throw new Doctrine_Plugin_Exception('If you wish to generate files then you must specify the path to generate the files in.');
|
throw new Doctrine_Plugin_Exception('If you wish to generate files then you must specify the path to generate the files in.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$def = $builder->buildDefinition($options, $columns, $relations);
|
$def = $builder->buildDefinition($options, $columns, $relations);
|
||||||
|
|
||||||
eval($def);
|
eval($def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,7 +34,12 @@ class Doctrine_Template_I18n extends Doctrine_Template
|
|||||||
{
|
{
|
||||||
protected $_translation;
|
protected $_translation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __construct
|
||||||
|
*
|
||||||
|
* @param string $array
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function __construct(array $options)
|
public function __construct(array $options)
|
||||||
{
|
{
|
||||||
$this->_plugin = new Doctrine_I18n($options);
|
$this->_plugin = new Doctrine_I18n($options);
|
||||||
@ -42,6 +47,7 @@ class Doctrine_Template_I18n extends Doctrine_Template
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* translation
|
* translation
|
||||||
|
*
|
||||||
* sets or retrieves the current translation language
|
* sets or retrieves the current translation language
|
||||||
*
|
*
|
||||||
* @return Doctrine_Record this object
|
* @return Doctrine_Record this object
|
||||||
@ -49,7 +55,15 @@ class Doctrine_Template_I18n extends Doctrine_Template
|
|||||||
public function translation($language = null)
|
public function translation($language = null)
|
||||||
{
|
{
|
||||||
$this->_translation = $language;
|
$this->_translation = $language;
|
||||||
|
|
||||||
|
return $this->_translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setUp
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->_plugin->setOption('table', $this->_table);
|
$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));
|
$this->hasMany($className . ' as Translation', array('local' => $id, 'foreign' => $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getI18n
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function getI18n()
|
public function getI18n()
|
||||||
{
|
{
|
||||||
return $this->_plugin;
|
return $this->_plugin;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user