1
0
mirror of synced 2024-12-14 07:06:04 +03:00
This commit is contained in:
zYne 2007-07-17 20:59:09 +00:00
parent 163c1aaa61
commit 1633b07f1d
3 changed files with 61 additions and 12 deletions

View File

@ -1370,7 +1370,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
public function revert($version)
{
$data = $this->_table->getAuditLog()->getVersion($this, $version);
$data = $this->_table
->getTemplate('Doctrine_Template_Versionable')
->getAuditLog()
->getVersion($this, $version);
$this->_data = $data[0];
}
@ -1387,6 +1390,37 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$tpl->setTableDefinition();
return $this;
}
public function actAs($tpl, $options = array())
{
if ( ! is_object($tpl)) {
if (class_exists($tpl)) {
$tpl = new $tpl($options);
} else {
$className = 'Doctrine_Template_' . ucwords(strtolower($tpl));
if ( ! class_exists($className)) {
throw new Doctrine_Record_Exception("Couldn't load plugin.");
}
$tpl = new $className($options);
}
}
if ( ! ($tpl instanceof Doctrine_Template)) {
throw new Doctrine_Record_Exception('Loaded plugin class is not an istance of Doctrine_Template.');
}
$className = get_class($tpl);
$this->_table->addTemplate($className, $tpl);
$tpl->setTable($this->_table);
$tpl->setUp();
$tpl->setTableDefinition();
return $this;
}
/**
* used to delete node from tree - MUST BE USE TO DELETE RECORD IF TABLE ACTS AS TREE
*

View File

@ -34,6 +34,7 @@ class Doctrine_Search
{
protected $_options = array('generateFiles' => true);
public function __construct(array $options)
{
$this->_options = array_merge($this->_options, $options);
@ -98,12 +99,17 @@ class Doctrine_Search
$columns = array('keyword' => array('type' => 'string',
'length' => 200,
'notnull' => true),
'notnull' => true,
'primary' => true,
),
'field' => array('type' => 'string',
'length' => 50,
'notnull' => true),
'notnull' => true,
'primary' => true),
'position' => array('type' => 'integer',
'length' => 8));
'length' => 8,
'primary' => true,
));
$id = $table->getIdentifier();
@ -120,6 +126,7 @@ class Doctrine_Search
$col = strtolower($name . '_' . $column);
$def['primary'] = true;
$fk[$col] = $def;
}

View File

@ -154,9 +154,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
protected $_parser;
/**
* @var Doctrine_AuditLog $_auditLog
* @var array $_templates an array containing all templates attached to this table
*/
protected $_auditLog;
protected $_templates;
/**
* the constructor
* @throws Doctrine_Connection_Exception if there are no opened connections
@ -1238,13 +1240,19 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
public function isTree() {
return ( ! is_null($this->options['treeImpl'])) ? true : false;
}
public function getAuditLog()
public function getTemplate($template)
{
if ( ! isset($this->_auditLog)) {
$this->_auditLog = new Doctrine_AuditLog($this);
if ( ! isset($this->_templates[$template])) {
throw new Doctrine_Table_Exception('Template ' . $template . ' not loaded');
}
return $this->_auditLog;
return $this->_templates[$template];
}
public function addTemplate($template, Doctrine_Template $impl)
{
$this->_templates[$template] = $impl;
}
/**
* returns a string representation of this object