From 90bf6241e4c55eb039dd9db263baff229bf58a67 Mon Sep 17 00:00:00 2001 From: zYne Date: Fri, 3 Aug 2007 11:25:53 +0000 Subject: [PATCH] --- lib/Doctrine/Record.php | 50 ------------------------------ lib/Doctrine/Record/Abstract.php | 53 +++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 51 deletions(-) diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 5696b84e4..6de670391 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -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 * diff --git a/lib/Doctrine/Record/Abstract.php b/lib/Doctrine/Record/Abstract.php index d6a2b53b0..31f479e9e 100644 --- a/lib/Doctrine/Record/Abstract.php +++ b/lib/Doctrine/Record/Abstract.php @@ -234,7 +234,58 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access foreach ($definitions as $name => $options) { $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