1
0
mirror of synced 2024-12-13 22:56:04 +03:00
This commit is contained in:
zYne 2007-08-03 11:25:53 +00:00
parent da1a6e38a9
commit 90bf6241e4
2 changed files with 52 additions and 51 deletions

View File

@ -1403,57 +1403,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
return $this;
}
/**
* loadTemplate
*
* @param string $template
*/
public function loadTemplate($template, array $options = array())
{
$tpl = new $template($options);
$tpl->setTable($this->_table);
$tpl->setUp();
$tpl->setTableDefinition();
return $this;
}
/**
* actAs
* loads a given plugin
*
* @param mixed $tpl
* @param array $options
*/
public function actAs($tpl, array $options = array())
{
if ( ! is_object($tpl)) {
if (class_exists($tpl, true)) {
$tpl = new $tpl($options);
} else {
$className = 'Doctrine_Template_' . ucwords(strtolower($tpl));
if ( ! class_exists($className, true)) {
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

@ -235,6 +235,57 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
$this->hasColumn($name, $options['type'], $options['length'], $options);
}
}
/**
* loadTemplate
*
* @param string $template
*/
public function loadTemplate($template, array $options = array())
{
$tpl = new $template($options);
$tpl->setTable($this->_table);
$tpl->setUp();
$tpl->setTableDefinition();
return $this;
}
/**
* actAs
* loads a given plugin
*
* @param mixed $tpl
* @param array $options
*/
public function actAs($tpl, array $options = array())
{
if ( ! is_object($tpl)) {
if (class_exists($tpl, true)) {
$tpl = new $tpl($options);
} else {
$className = 'Doctrine_Template_' . ucwords(strtolower($tpl));
if ( ! class_exists($className, true)) {
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;
}
/**
* check
* adds a check constraint