This commit is contained in:
parent
163c1aaa61
commit
1633b07f1d
@ -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
|
||||
*
|
||||
|
@ -33,6 +33,7 @@
|
||||
class Doctrine_Search
|
||||
{
|
||||
protected $_options = array('generateFiles' => true);
|
||||
|
||||
|
||||
public function __construct(array $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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
return $this->_auditLog;
|
||||
if ( ! isset($this->_templates[$template])) {
|
||||
throw new Doctrine_Table_Exception('Template ' . $template . ' not loaded');
|
||||
}
|
||||
|
||||
return $this->_templates[$template];
|
||||
}
|
||||
|
||||
public function addTemplate($template, Doctrine_Template $impl)
|
||||
{
|
||||
$this->_templates[$template] = $impl;
|
||||
}
|
||||
/**
|
||||
* returns a string representation of this object
|
||||
|
Loading…
Reference in New Issue
Block a user